diff --git a/src/java/davmail/exchange/dav/DavExchangeSession.java b/src/java/davmail/exchange/dav/DavExchangeSession.java index ebc93d94..bb199e08 100644 --- a/src/java/davmail/exchange/dav/DavExchangeSession.java +++ b/src/java/davmail/exchange/dav/DavExchangeSession.java @@ -1086,9 +1086,15 @@ public class DavExchangeSession extends ExchangeSession { try { String messageHeaders = getItemProperty(permanentUrl, "messageheaders"); if (messageHeaders != null) { - final String MS_HEADER = "Microsoft Mail Internet Headers Version 2.0\r\n"; + final String MS_HEADER = "Microsoft Mail Internet Headers Version 2.0"; if (messageHeaders.startsWith(MS_HEADER)) { messageHeaders = messageHeaders.substring(MS_HEADER.length()); + if (messageHeaders.charAt(0) == '\r') { + messageHeaders = messageHeaders.substring(1); + } + if (messageHeaders.charAt(0) == '\n') { + messageHeaders = messageHeaders.substring(1); + } } // workaround for messages in Sent folder if (messageHeaders.indexOf("From:") < 0) { diff --git a/src/java/davmail/imap/ImapConnection.java b/src/java/davmail/imap/ImapConnection.java index 11dd6c15..c331e26c 100644 --- a/src/java/davmail/imap/ImapConnection.java +++ b/src/java/davmail/imap/ImapConnection.java @@ -1941,34 +1941,4 @@ public class ImapConnection extends AbstractConnection { } } - public void testInvalidHeaders() throws MessagingException { - String messageHeaders = "Microsoft Mail Internet Headers Version 2.0\r\n" + - "Received: from mail.litwareinc.com ([10.54.108.101]) by mail.proseware.com with Microsoft SMTPSVC(6.0.3790.0);\r\n" + - "Wed, 12 Dec 2007 13:39:22 -0800\r\n" + - "Received: from mail ([10.54.108.23] RDNS failed) by mail.litware.com with Microsoft SMTPSVC(6.0.3790.0);\r\n" + - "Wed, 12 Dec 2007 13:38:49 -0800\r\n" + - "From: \"Kelly J. Weadock\" \n" + - "To: \n" + - "Cc: \n" + - "Subject: Review of staff assignments\n" + - "Date: Wed, 12 Dec 2007 13:38:31 -0800\n" + - "MIME-Version: 1.0\n" + - "Content-Type: multipart/mixed;\n" + - "X-Mailer: Microsoft Office Outlook, Build 12.0.4210\n" + - "X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165\n" + - "Thread-Index: AcON3CInEwkfLOQsQGeK8VCv3M+ipA==\n" + - "Return-Path: kelly@litware.com\n" + - "Message-ID: \n" + - "X-OriginalArrivalTime: 12 Dec 2007 21:38:50.0145 (UTC)"; - final String MS_HEADER = "Microsoft Mail Internet Headers Version 2.0\r\n"; - if (messageHeaders.startsWith(MS_HEADER)) { - messageHeaders = messageHeaders.substring(MS_HEADER.length()); - } - Enumeration enumeration = new InternetHeaders(new ByteArrayInputStream(messageHeaders.getBytes())).getAllHeaderLines(); - while (enumeration.hasMoreElements()) { - System.out.println(enumeration.nextElement()); - } - - } - } \ No newline at end of file