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:
mguessan 2008-01-31 22:17:44 +00:00
parent 7ffce1a1bc
commit dfeced6478
1 changed files with 26 additions and 1 deletions

View File

@ -792,6 +792,18 @@ public class ExchangeSession {
reader.readLine();
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)) {
if (hasAttachment && mstnefDetected) {
line = null;
@ -805,8 +817,17 @@ public class ExchangeSession {
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
if (boundary != null) {
if (boundary != null && mstnefDetected) {
loadAttachments();
// TODO : test actual header values
result.append("\n--").append(boundary)
@ -884,6 +905,9 @@ public class ExchangeSession {
loadAttachments();
writeMimeMessage(reader, os, mimeHeader);
if (attachmentIndex - 1 != attachments.size()) {
LOGGER.error("Found " + (attachmentIndex - 1) + " attachments, expected " + attachments.size());
}
}
os.flush();
} finally {
@ -947,6 +971,7 @@ public class ExchangeSession {
}
}
}
// write mime end marker
if (line != null) {
os.write(line.getBytes());