Force utf-8 charset in text/calendar attachments and replace invalid characters

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@125 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2008-02-14 14:20:37 +00:00
parent 3be56bc928
commit f6c66f5106
1 changed files with 17 additions and 0 deletions

View File

@ -619,6 +619,22 @@ public class ExchangeSession {
while ((line = reader.readLine()) != null) {
if (".".equals(line)) {
line = "..";
// patch text/calendar to include utf-8 encoding
} else if ("Content-Type: text/calendar;".equals(line)) {
StringBuffer headerBuffer = new StringBuffer();
headerBuffer.append(line);
while ((line = reader.readLine()) != null && line.startsWith("\t")) {
headerBuffer.append((char) 13);
headerBuffer.append((char) 10);
headerBuffer.append(line);
}
if (headerBuffer.indexOf("charset") < 0) {
headerBuffer.append(";charset=utf-8");
}
headerBuffer.append((char) 13);
headerBuffer.append((char) 10);
headerBuffer.append(line);
line = headerBuffer.toString();
// detect html body to patch Exchange html body
} else if (line.startsWith("<html")) {
inHTML = true;
@ -627,6 +643,7 @@ public class ExchangeSession {
}
if (inHTML) {
line = line.replaceAll("&#8217;", "'");
line = line.replaceAll("&#8230;", "...");
}
isoWriter.write(line);
isoWriter.write((char) 13);