1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-14 03:32:22 -05:00

IMAP: improve complex content-type handling in BODYSTRUCTURE

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@775 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-10-09 23:08:04 +00:00
parent 432e43ae14
commit 1a7f3ec005

View File

@ -674,12 +674,18 @@ public class ImapConnection extends AbstractConnection {
int charsetindex = contentType.indexOf("charset="); int charsetindex = contentType.indexOf("charset=");
if (charsetindex >= 0) { if (charsetindex >= 0) {
buffer.append(" (\"CHARSET\" "); buffer.append(" (\"CHARSET\" ");
int charsetEndIndex = Math.max(contentType.indexOf(' '), contentType.length()); int charsetSemiColonIndex = contentType.indexOf(';', charsetindex);
int charsetEndIndex;
if (charsetSemiColonIndex > 0) {
charsetEndIndex = charsetSemiColonIndex;
} else {
charsetEndIndex = contentType.length();
}
String charSet = contentType.substring(charsetindex + "charset=".length(), charsetEndIndex); String charSet = contentType.substring(charsetindex + "charset=".length(), charsetEndIndex);
if (!charSet.startsWith("\"")) { if (!charSet.startsWith("\"")) {
buffer.append('"'); buffer.append('"');
} }
buffer.append(charSet.toUpperCase()); buffer.append(charSet.trim().toUpperCase());
if (!charSet.endsWith("\"")) { if (!charSet.endsWith("\"")) {
buffer.append('"'); buffer.append('"');
} }