mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-07 03:38:05 -05:00
Another Exchange invalid message header fix : ms-tnef inside MIME part
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@115 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
7ffce1a1bc
commit
dfeced6478
@ -792,6 +792,18 @@ public class ExchangeSession {
|
|||||||
reader.readLine();
|
reader.readLine();
|
||||||
mstnefDetected = true;
|
mstnefDetected = true;
|
||||||
|
|
||||||
|
} else if (line.startsWith(CONTENT_TYPE_HEADER)) {
|
||||||
|
if (line.endsWith(";")) {
|
||||||
|
result.append(line);
|
||||||
|
result.append("\n");
|
||||||
|
|
||||||
|
// boundary is on next line
|
||||||
|
line = reader.readLine();
|
||||||
|
}
|
||||||
|
if (line != null && line.indexOf("boundary=\"") >= 0) {
|
||||||
|
boundary = line.substring(line.indexOf("boundary=\"") + 10, line.length() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
} else if (line.startsWith(CONTENT_TRANSFER_ENCODING_HEADER)) {
|
} else if (line.startsWith(CONTENT_TRANSFER_ENCODING_HEADER)) {
|
||||||
if (hasAttachment && mstnefDetected) {
|
if (hasAttachment && mstnefDetected) {
|
||||||
line = null;
|
line = null;
|
||||||
@ -805,8 +817,17 @@ public class ExchangeSession {
|
|||||||
line = reader.readLine();
|
line = reader.readLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// look for ms-tnef inside mime part headers
|
||||||
|
while (line != null) {
|
||||||
|
if (line.equals(CONTENT_TYPE_HEADER + "application/ms-tnef;")) {
|
||||||
|
LOGGER.debug("application/ms-tnef detected inside part headers");
|
||||||
|
mstnefDetected = true;
|
||||||
|
}
|
||||||
|
line = reader.readLine();
|
||||||
|
}
|
||||||
|
|
||||||
// exchange message : create mime part headers
|
// exchange message : create mime part headers
|
||||||
if (boundary != null) {
|
if (boundary != null && mstnefDetected) {
|
||||||
loadAttachments();
|
loadAttachments();
|
||||||
// TODO : test actual header values
|
// TODO : test actual header values
|
||||||
result.append("\n--").append(boundary)
|
result.append("\n--").append(boundary)
|
||||||
@ -884,6 +905,9 @@ public class ExchangeSession {
|
|||||||
|
|
||||||
loadAttachments();
|
loadAttachments();
|
||||||
writeMimeMessage(reader, os, mimeHeader);
|
writeMimeMessage(reader, os, mimeHeader);
|
||||||
|
if (attachmentIndex - 1 != attachments.size()) {
|
||||||
|
LOGGER.error("Found " + (attachmentIndex - 1) + " attachments, expected " + attachments.size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
os.flush();
|
os.flush();
|
||||||
} finally {
|
} finally {
|
||||||
@ -947,6 +971,7 @@ public class ExchangeSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// write mime end marker
|
// write mime end marker
|
||||||
if (line != null) {
|
if (line != null) {
|
||||||
os.write(line.getBytes());
|
os.write(line.getBytes());
|
||||||
|
Loading…
Reference in New Issue
Block a user