From f6c66f5106eb07275ba6247dd0d59759d25d6c81 Mon Sep 17 00:00:00 2001 From: mguessan Date: Thu, 14 Feb 2008 14:20:37 +0000 Subject: [PATCH] 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 --- src/java/davmail/exchange/ExchangeSession.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index c8b67f6a..fda16e7e 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -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("