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
This commit is contained in:
mguessan 2007-11-13 22:21:36 +00:00
parent 44e4ebf07c
commit 3f7f9aca5c
1 changed files with 10 additions and 11 deletions

View File

@ -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;
}