1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 19:22:22 -05:00

IMAP: fix from kolos_dm: implement attachment name in BODYSTRUCTURE

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1505 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-10-14 21:08:27 +00:00
parent e00158f524
commit 4acd9dfe24

View File

@ -1014,8 +1014,12 @@ public class ImapConnection extends AbstractConnection {
// extended content type // extended content type
buffer.append(contentType.substring(slashIndex + 1, semiColonIndex).trim().toUpperCase()).append('\"'); buffer.append(contentType.substring(slashIndex + 1, semiColonIndex).trim().toUpperCase()).append('\"');
int charsetindex = contentType.indexOf("charset="); int charsetindex = contentType.indexOf("charset=");
int nameindex = contentType.indexOf("name=");
if (charsetindex >= 0 || nameindex >= 0) {
buffer.append(" (");
if (charsetindex >=0) { if (charsetindex >=0) {
buffer.append(" (\"CHARSET\" "); buffer.append("\"CHARSET\" ");
int charsetSemiColonIndex = contentType.indexOf(';', charsetindex); int charsetSemiColonIndex = contentType.indexOf(';', charsetindex);
int charsetEndIndex; int charsetEndIndex;
if (charsetSemiColonIndex > 0) { if (charsetSemiColonIndex > 0) {
@ -1031,6 +1035,30 @@ public class ImapConnection extends AbstractConnection {
if (!charSet.endsWith("\"")) { if (!charSet.endsWith("\"")) {
buffer.append('"'); buffer.append('"');
} }
}
if (nameindex >= 0) {
if (charsetindex >=0) {
buffer.append(' ');
}
buffer.append("\"NAME\" ");
int nameSemiColonIndex = contentType.indexOf(';', nameindex);
int nameEndIndex;
if (nameSemiColonIndex > 0) {
nameEndIndex = nameSemiColonIndex;
} else {
nameEndIndex = contentType.length();
}
String name = contentType.substring(nameindex + "name=".length(), nameEndIndex);
if (!name.startsWith("\"")) {
buffer.append('"');
}
buffer.append(name.trim());
if (!name.endsWith("\"")) {
buffer.append('"');
}
}
buffer.append(')'); buffer.append(')');
} else { } else {
buffer.append(" NIL"); buffer.append(" NIL");