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
1 changed files with 8 additions and 2 deletions

View File

@ -674,12 +674,18 @@ public class ImapConnection extends AbstractConnection {
int charsetindex = contentType.indexOf("charset=");
if (charsetindex >= 0) {
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);
if (!charSet.startsWith("\"")) {
buffer.append('"');
}
buffer.append(charSet.toUpperCase());
buffer.append(charSet.trim().toUpperCase());
if (!charSet.endsWith("\"")) {
buffer.append('"');
}