1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-14 11:42:23 -05:00

Caldav: new CRLF in urlcompname patch for EWS, use _x000D__x000A_ as encoded value

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1744 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2011-07-21 22:40:08 +00:00
parent 7bd0cbc5d0
commit 7a31659473
2 changed files with 15 additions and 3 deletions

View File

@ -1174,6 +1174,9 @@ 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

@ -133,6 +133,7 @@ public final class StringUtil {
private static final Pattern GT_PATTERN = Pattern.compile(">"); private static final Pattern GT_PATTERN = Pattern.compile(">");
private static final Pattern QUOTE_PATTERN = Pattern.compile("\""); private static final Pattern QUOTE_PATTERN = Pattern.compile("\"");
private static final Pattern CR_PATTERN = Pattern.compile("\r");
private static final Pattern LF_PATTERN = Pattern.compile("\n"); private static final Pattern LF_PATTERN = Pattern.compile("\n");
private static final Pattern URLENCODED_AMP_PATTERN = Pattern.compile("%26"); private static final Pattern URLENCODED_AMP_PATTERN = Pattern.compile("%26");
@ -142,6 +143,8 @@ public final class StringUtil {
private static final Pattern ENCODED_GT_PATTERN = Pattern.compile(">"); private static final Pattern ENCODED_GT_PATTERN = Pattern.compile(">");
private static final Pattern F8FF_PATTERN = Pattern.compile("_xF8FF_"); private static final Pattern F8FF_PATTERN = Pattern.compile("_xF8FF_");
private static final Pattern X0D0A_PATTERN = Pattern.compile("_x000D__x000A_");
private static final Pattern PLUS_PATTERN = Pattern.compile("\\+"); private static final Pattern PLUS_PATTERN = Pattern.compile("\\+");
private static final Pattern COLON_PATTERN = Pattern.compile(":"); private static final Pattern COLON_PATTERN = Pattern.compile(":");
private static final Pattern SLASH_PATTERN = Pattern.compile("/"); private static final Pattern SLASH_PATTERN = Pattern.compile("/");
@ -213,6 +216,12 @@ public final class StringUtil {
if (result.indexOf('"') >= 0) { if (result.indexOf('"') >= 0) {
result = QUOTE_PATTERN.matcher(result).replaceAll("""); result = QUOTE_PATTERN.matcher(result).replaceAll(""");
} }
if (result.indexOf('\r') >=0) {
result = CR_PATTERN.matcher(result).replaceAll("
");
}
if (result.indexOf('\n') >=0) {
result = LF_PATTERN.matcher(result).replaceAll("
");
}
} }
return result; return result;
} }
@ -295,8 +304,8 @@ public final class StringUtil {
if (result.indexOf('"') >= 0) { if (result.indexOf('"') >= 0) {
result = QUOTE_PATTERN.matcher(result).replaceAll("%22"); result = QUOTE_PATTERN.matcher(result).replaceAll("%22");
} }
if (result.indexOf('\n') >= 0) { if (result.indexOf("_x000D__x000A_") >= 0) {
result = LF_PATTERN.matcher(result).replaceAll("%0A"); result = X0D0A_PATTERN.matcher(result).replaceAll("\r\n");
} }
return result; return result;
} }