try to get inline attachment by content id when name not provided

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@81 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2007-10-09 11:37:47 +00:00
parent dfd6cc12ee
commit 1dfae49a2d
1 changed files with 18 additions and 0 deletions

View File

@ -92,6 +92,7 @@ public class ExchangeSession {
public static final String CONTENT_TYPE_HEADER = "content-type: ";
public static final String CONTENT_TRANSFER_ENCODING_HEADER = "content-transfer-encoding: ";
public static final String CONTENT_DISPOSITION_HEADER = "content-disposition: ";
public static final String CONTENT_ID_HEADER = "content-id: ";
private static final int DEFAULT_KEEP_DELAY = 30;
@ -921,6 +922,14 @@ public class ExchangeSession {
if (attachment == null && (partHeader.name == null || "winmail.dat".equals(partHeader.name))) {
attachment = attachmentsMap.get(String.valueOf(attachmentIndex));
}
// try to get attachment by content id
if (attachment == null && partHeader.contentId != null) {
for (Attachment entry : attachmentsMap.values()) {
if (partHeader.contentId.equals(entry.contentid)) {
attachment = entry;
}
}
}
// try to get by index if attachment renamed to application
if (attachment == null && partHeader.name != null) {
if (currentAttachment != null && currentAttachment.name.startsWith("application")) {
@ -1417,6 +1426,7 @@ public class ExchangeSession {
public String contentTransferEncoding = null;
public String boundary = null;
public String name = null;
public String contentId = null;
/**
* filename in Content-Disposition header
*/
@ -1556,6 +1566,14 @@ public class ExchangeSession {
fileName += line.substring(1, line.lastIndexOf("\""));
}
}
} else if (lineToCompare.startsWith(CONTENT_ID_HEADER)) {
contentId = line.substring(CONTENT_ID_HEADER.length()).trim();
if (contentId.startsWith("<")) {
contentId = contentId.substring(1);
}
if (contentId.endsWith(">")) {
contentId = contentId.substring(0, contentId.length()-1);
}
}
line = fixRenamedAttachment(reader.readLine(), currentAttachmentName);
}