mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 19:22:22 -05:00
Caldav: fix 3190219, regression on quote encoding since 3165749 fix
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1632 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
b608851065
commit
b2ff79a8a3
@ -488,11 +488,11 @@ public abstract class EWSMethod extends PostMethod {
|
||||
for (String key : fieldNames) {
|
||||
if ("MeetingTimeZone".equals(key)) {
|
||||
writer.write("<t:MeetingTimeZone TimeZoneName=\"");
|
||||
writer.write(StringUtil.xmlEncode(get(key)));
|
||||
writer.write(StringUtil.xmlEncodeAttribute(get(key)));
|
||||
writer.write("\"></t:MeetingTimeZone>");
|
||||
} else if ("StartTimeZone".equals(key)) {
|
||||
writer.write("<t:StartTimeZone Id=\"");
|
||||
writer.write(StringUtil.xmlEncode(get(key)));
|
||||
writer.write(StringUtil.xmlEncodeAttribute(get(key)));
|
||||
writer.write("\"></t:StartTimeZone>");
|
||||
} else {
|
||||
writer.write("<t:");
|
||||
|
@ -53,6 +53,10 @@ public class EwsExchangeSession extends ExchangeSession {
|
||||
|
||||
protected static final int PAGE_SIZE = 100;
|
||||
|
||||
/**
|
||||
* Message types.
|
||||
* @see http://msdn.microsoft.com/en-us/library/aa565652%28v=EXCHG.140%29.aspx
|
||||
*/
|
||||
protected static final Set<String> MESSAGE_TYPES = new HashSet<String>();
|
||||
|
||||
static {
|
||||
@ -70,6 +74,18 @@ public class EwsExchangeSession extends ExchangeSession {
|
||||
//MESSAGE_TYPES.add("Contact");
|
||||
//MESSAGE_TYPES.add("DistributionList");
|
||||
//MESSAGE_TYPES.add("Task");
|
||||
|
||||
//ReplyToItem
|
||||
//ForwardItem
|
||||
//ReplyAllToItem
|
||||
//AcceptItem
|
||||
//TentativelyAcceptItem
|
||||
//DeclineItem
|
||||
//CancelCalendarItem
|
||||
//RemoveItem
|
||||
//PostReplyItem
|
||||
//SuppressReadReceipt
|
||||
//AcceptSharingInvitation
|
||||
}
|
||||
|
||||
protected Map<String, String> folderIdMap;
|
||||
@ -602,7 +618,7 @@ public class EwsExchangeSession extends ExchangeSession {
|
||||
buffer.append("<t:Constant Value=\"");
|
||||
// encode urlcompname
|
||||
if (fieldURI instanceof ExtendedFieldURI && "0x10f3".equals(((ExtendedFieldURI) fieldURI).propertyTag)) {
|
||||
buffer.append(StringUtil.xmlEncode(StringUtil.encodeUrlcompname(value)));
|
||||
buffer.append(StringUtil.xmlEncodeAttribute(StringUtil.encodeUrlcompname(value)));
|
||||
} else if (fieldURI instanceof ExtendedFieldURI
|
||||
&& ((ExtendedFieldURI) fieldURI).propertyType == ExtendedFieldURI.PropertyType.Integer) {
|
||||
// check value
|
||||
@ -614,7 +630,7 @@ public class EwsExchangeSession extends ExchangeSession {
|
||||
buffer.append('0');
|
||||
}
|
||||
} else {
|
||||
buffer.append(StringUtil.xmlEncode(value));
|
||||
buffer.append(StringUtil.xmlEncodeAttribute(value));
|
||||
}
|
||||
buffer.append("\"/>");
|
||||
if (operator != Operator.Contains) {
|
||||
|
@ -56,7 +56,7 @@ public class IndexedFieldURI implements FieldURI {
|
||||
buffer.append("<t:").append(collectionName).append('>');
|
||||
}
|
||||
buffer.append("<t:Entry Key=\"").append(fieldIndex).append("\">");
|
||||
buffer.append(StringUtil.xmlEncode(value));
|
||||
buffer.append(StringUtil.xmlEncodeAttribute(value));
|
||||
buffer.append("</t:Entry>");
|
||||
if (itemType != null) {
|
||||
buffer.append("</t:").append(collectionName).append('>');
|
||||
|
@ -53,9 +53,9 @@ public class TwoOperandExpression implements SearchExpression {
|
||||
buffer.append("<t:FieldURIOrConstant><t:Constant Value=\"");
|
||||
// encode urlcompname
|
||||
if (fieldURI instanceof ExtendedFieldURI && "0x10f3".equals(((ExtendedFieldURI) fieldURI).propertyTag)) {
|
||||
buffer.append(StringUtil.xmlEncode(StringUtil.encodeUrlcompname(value)));
|
||||
buffer.append(StringUtil.xmlEncodeAttribute(StringUtil.encodeUrlcompname(value)));
|
||||
} else {
|
||||
buffer.append(StringUtil.xmlEncode(value));
|
||||
buffer.append(StringUtil.xmlEncodeAttribute(value));
|
||||
}
|
||||
buffer.append("\"/></t:FieldURIOrConstant>");
|
||||
|
||||
|
@ -60,17 +60,17 @@ public class UnindexedFieldURI implements FieldURI {
|
||||
}
|
||||
if ("MeetingTimeZone".equals(fieldName)) {
|
||||
buffer.append("<t:MeetingTimeZone TimeZoneName=\"");
|
||||
buffer.append(StringUtil.xmlEncode(value));
|
||||
buffer.append(StringUtil.xmlEncodeAttribute(value));
|
||||
buffer.append("\"></t:MeetingTimeZone>");
|
||||
} else if ("StartTimeZone".equals(fieldName)) {
|
||||
buffer.append("<t:StartTimeZone Id=\"");
|
||||
buffer.append(StringUtil.xmlEncode(value));
|
||||
buffer.append(StringUtil.xmlEncodeAttribute(value));
|
||||
buffer.append("\"></t:StartTimeZone>");
|
||||
} else {
|
||||
buffer.append("<t:");
|
||||
buffer.append(fieldName);
|
||||
buffer.append('>');
|
||||
buffer.append(StringUtil.xmlEncode(value));
|
||||
buffer.append(StringUtil.xmlEncodeAttribute(value));
|
||||
buffer.append("</t:");
|
||||
buffer.append(fieldName);
|
||||
buffer.append('>');
|
||||
|
@ -179,7 +179,7 @@ public final class StringUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* Need to encode xml for iCal.
|
||||
* Xml encode content.
|
||||
*
|
||||
* @param name decoded name
|
||||
* @return name encoded name
|
||||
@ -203,6 +203,22 @@ public final class StringUtil {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Xml encode inside attribute.
|
||||
*
|
||||
* @param name decoded name
|
||||
* @return name encoded name
|
||||
*/
|
||||
public static String xmlEncodeAttribute(String name) {
|
||||
String result = xmlEncode(name);
|
||||
if (result != null) {
|
||||
if (result.indexOf('"') >= 0) {
|
||||
result = QUOTE_PATTERN.matcher(result).replaceAll(""");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Need to decode xml for iCal
|
||||
*
|
||||
|
@ -475,7 +475,7 @@ public class TestExchangeSessionContact extends AbstractExchangeSessionTestCase
|
||||
vCardWriter.appendProperty("FN", "common name");
|
||||
vCardWriter.endCard();
|
||||
|
||||
itemName = "test {<:&'>+} accentué.vcf";
|
||||
itemName = "test {<:&'>} \"accentué.vcf";
|
||||
|
||||
ExchangeSession.ItemResult result = session.createOrUpdateContact("testcontactfolder", itemName, vCardWriter.toString(), null, null);
|
||||
assertEquals(201, result.status);
|
||||
|
Loading…
Reference in New Issue
Block a user