From 3f7f9aca5caf143ed7047fe76766e78ada05330c Mon Sep 17 00:00:00 2001 From: mguessan Date: Tue, 13 Nov 2007 22:21:36 +0000 Subject: [PATCH] Do not decode attachment URL twice (fails with % in message title) git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@104 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- .../davmail/exchange/ExchangeSession.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index 2a69604b..dc5cda04 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -958,13 +958,12 @@ public class ExchangeSession { } catch (MessagingException e) { throw new IOException(e + " " + e.getMessage()); } - String decodedPath = URIUtil.decode(attachment.href); if ("message/rfc822".equalsIgnoreCase(mimeHeader.contentType)) { String messageAttachmentPath = null; // Get real attachment path from owa page content - GetMethod method = new GetMethod(URIUtil.encodePath(decodedPath)); + GetMethod method = new GetMethod(URIUtil.encodePath(attachment.href)); wdr.retrieveSessionInstance().executeMethod(method); String body = method.getResponseBodyAsString(); final String URL_DECLARATION = "var g_szURL\t= \""; @@ -986,7 +985,7 @@ public class ExchangeSession { attachedMessage.write(quotedOs); } else { - GetMethod method = new GetMethod(URIUtil.encodePath(decodedPath)); + GetMethod method = new GetMethod(URIUtil.encodePath(attachment.href)); wdr.retrieveSessionInstance().executeMethod(method); // encode attachment @@ -1351,14 +1350,14 @@ public class ExchangeSession { for (Attachment currentAttachment : attachments) { if ((partHeader.name != null && partHeader.name.equals(currentAttachment.name)) || - // TODO : test if .eml extension could be stripped from attachment name directly - // try to get email attachment with .eml extension - (partHeader.name != null && (partHeader.name + ".eml").equals(currentAttachment.name)) || - // try to get attachment by content id - (partHeader.contentId != null && partHeader.contentId.equals(currentAttachment.contentid)) || - // try to get attachment with Content-Disposition header - (partHeader.fileName != null && partHeader.fileName.equals(currentAttachment.name)) - ){ + // TODO : test if .eml extension could be stripped from attachment name directly + // try to get email attachment with .eml extension + (partHeader.name != null && (partHeader.name + ".eml").equals(currentAttachment.name)) || + // try to get attachment by content id + (partHeader.contentId != null && partHeader.contentId.equals(currentAttachment.contentid)) || + // try to get attachment with Content-Disposition header + (partHeader.fileName != null && partHeader.fileName.equals(currentAttachment.name)) + ) { attachment = currentAttachment; break; }