1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 19:22:22 -05:00

Caldav: additional fix for CRLF in urlcompname

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1771 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2011-08-09 13:17:13 +00:00
parent 9b6c21de92
commit 1569081efe
2 changed files with 4 additions and 6 deletions

View File

@ -1000,7 +1000,7 @@ public class EwsExchangeSession extends ExchangeSession {
permanentUrl = response.get(Field.get("permanenturl").getResponseName()); permanentUrl = response.get(Field.get("permanenturl").getResponseName());
etag = response.get(Field.get("etag").getResponseName()); etag = response.get(Field.get("etag").getResponseName());
displayName = response.get(Field.get("displayname").getResponseName()); displayName = response.get(Field.get("displayname").getResponseName());
itemName = response.get(Field.get("urlcompname").getResponseName()); itemName = StringUtil.decodeUrlcompname(response.get(Field.get("urlcompname").getResponseName()));
// workaround for missing urlcompname in Exchange 2010 // workaround for missing urlcompname in Exchange 2010
if (itemName == null) { if (itemName == null) {
itemName = StringUtil.base64ToUrl(itemId.id) + ".EML"; itemName = StringUtil.base64ToUrl(itemId.id) + ".EML";
@ -1182,9 +1182,6 @@ public class EwsExchangeSession extends ExchangeSession {
// workaround for missing urlcompname in Exchange 2010 // workaround for missing urlcompname in Exchange 2010
if (itemName == null) { if (itemName == null) {
itemName = StringUtil.base64ToUrl(itemId.id) + ".EML"; itemName = StringUtil.base64ToUrl(itemId.id) + ".EML";
} else if (itemName.indexOf('\n') >= 0) {
// encode line feed
itemName = itemName.replaceAll("\n", "_x000D__x000A_");
} }
String instancetype = response.get(Field.get("instancetype").getResponseName()); String instancetype = response.get(Field.get("instancetype").getResponseName());
boolean isrecurring = "true".equals(response.get(Field.get("isrecurring").getResponseName())); boolean isrecurring = "true".equals(response.get(Field.get("isrecurring").getResponseName()));

View File

@ -144,7 +144,7 @@ public final class StringUtil {
private static final Pattern URLENCODED_LT_PATTERN = Pattern.compile("%3C"); private static final Pattern URLENCODED_LT_PATTERN = Pattern.compile("%3C");
private static final Pattern URLENCODED_GT_PATTERN = Pattern.compile("%3E"); private static final Pattern URLENCODED_GT_PATTERN = Pattern.compile("%3E");
private static final Pattern URLENCODED_QUOTE_PATTERN = Pattern.compile("%22"); private static final Pattern URLENCODED_QUOTE_PATTERN = Pattern.compile("%22");
private static final Pattern URLENCODED_X0D0A_PATTERN = Pattern.compile("\r\n"); private static final Pattern URLENCODED_X0D0A_PATTERN = Pattern.compile("\n");
private static final Pattern URLENCODED_PERCENT_PATTERN = Pattern.compile("%25"); private static final Pattern URLENCODED_PERCENT_PATTERN = Pattern.compile("%25");
private static final Pattern ENCODED_AMP_PATTERN = Pattern.compile("&"); private static final Pattern ENCODED_AMP_PATTERN = Pattern.compile("&");
@ -351,7 +351,8 @@ public final class StringUtil {
if (result.indexOf("%22") >= 0) { if (result.indexOf("%22") >= 0) {
result = URLENCODED_QUOTE_PATTERN.matcher(result).replaceAll("\""); result = URLENCODED_QUOTE_PATTERN.matcher(result).replaceAll("\"");
} }
if (result.indexOf("\r\n") >= 0) { // CRLF is replaced with LF in response
if (result.indexOf('\n') >= 0) {
result = URLENCODED_X0D0A_PATTERN.matcher(result).replaceAll("_x000D__x000A_"); result = URLENCODED_X0D0A_PATTERN.matcher(result).replaceAll("_x000D__x000A_");
} }
if (result.indexOf("%25") >= 0) { if (result.indexOf("%25") >= 0) {