mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-05 18:58:02 -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) {
|
for (String key : fieldNames) {
|
||||||
if ("MeetingTimeZone".equals(key)) {
|
if ("MeetingTimeZone".equals(key)) {
|
||||||
writer.write("<t:MeetingTimeZone TimeZoneName=\"");
|
writer.write("<t:MeetingTimeZone TimeZoneName=\"");
|
||||||
writer.write(StringUtil.xmlEncode(get(key)));
|
writer.write(StringUtil.xmlEncodeAttribute(get(key)));
|
||||||
writer.write("\"></t:MeetingTimeZone>");
|
writer.write("\"></t:MeetingTimeZone>");
|
||||||
} else if ("StartTimeZone".equals(key)) {
|
} else if ("StartTimeZone".equals(key)) {
|
||||||
writer.write("<t:StartTimeZone Id=\"");
|
writer.write("<t:StartTimeZone Id=\"");
|
||||||
writer.write(StringUtil.xmlEncode(get(key)));
|
writer.write(StringUtil.xmlEncodeAttribute(get(key)));
|
||||||
writer.write("\"></t:StartTimeZone>");
|
writer.write("\"></t:StartTimeZone>");
|
||||||
} else {
|
} else {
|
||||||
writer.write("<t:");
|
writer.write("<t:");
|
||||||
|
@ -53,6 +53,10 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
|
|
||||||
protected static final int PAGE_SIZE = 100;
|
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>();
|
protected static final Set<String> MESSAGE_TYPES = new HashSet<String>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@ -70,6 +74,18 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
//MESSAGE_TYPES.add("Contact");
|
//MESSAGE_TYPES.add("Contact");
|
||||||
//MESSAGE_TYPES.add("DistributionList");
|
//MESSAGE_TYPES.add("DistributionList");
|
||||||
//MESSAGE_TYPES.add("Task");
|
//MESSAGE_TYPES.add("Task");
|
||||||
|
|
||||||
|
//ReplyToItem
|
||||||
|
//ForwardItem
|
||||||
|
//ReplyAllToItem
|
||||||
|
//AcceptItem
|
||||||
|
//TentativelyAcceptItem
|
||||||
|
//DeclineItem
|
||||||
|
//CancelCalendarItem
|
||||||
|
//RemoveItem
|
||||||
|
//PostReplyItem
|
||||||
|
//SuppressReadReceipt
|
||||||
|
//AcceptSharingInvitation
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<String, String> folderIdMap;
|
protected Map<String, String> folderIdMap;
|
||||||
@ -602,7 +618,7 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
buffer.append("<t:Constant Value=\"");
|
buffer.append("<t:Constant Value=\"");
|
||||||
// encode urlcompname
|
// encode urlcompname
|
||||||
if (fieldURI instanceof ExtendedFieldURI && "0x10f3".equals(((ExtendedFieldURI) fieldURI).propertyTag)) {
|
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
|
} else if (fieldURI instanceof ExtendedFieldURI
|
||||||
&& ((ExtendedFieldURI) fieldURI).propertyType == ExtendedFieldURI.PropertyType.Integer) {
|
&& ((ExtendedFieldURI) fieldURI).propertyType == ExtendedFieldURI.PropertyType.Integer) {
|
||||||
// check value
|
// check value
|
||||||
@ -614,7 +630,7 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
buffer.append('0');
|
buffer.append('0');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
buffer.append(StringUtil.xmlEncode(value));
|
buffer.append(StringUtil.xmlEncodeAttribute(value));
|
||||||
}
|
}
|
||||||
buffer.append("\"/>");
|
buffer.append("\"/>");
|
||||||
if (operator != Operator.Contains) {
|
if (operator != Operator.Contains) {
|
||||||
|
@ -56,7 +56,7 @@ public class IndexedFieldURI implements FieldURI {
|
|||||||
buffer.append("<t:").append(collectionName).append('>');
|
buffer.append("<t:").append(collectionName).append('>');
|
||||||
}
|
}
|
||||||
buffer.append("<t:Entry Key=\"").append(fieldIndex).append("\">");
|
buffer.append("<t:Entry Key=\"").append(fieldIndex).append("\">");
|
||||||
buffer.append(StringUtil.xmlEncode(value));
|
buffer.append(StringUtil.xmlEncodeAttribute(value));
|
||||||
buffer.append("</t:Entry>");
|
buffer.append("</t:Entry>");
|
||||||
if (itemType != null) {
|
if (itemType != null) {
|
||||||
buffer.append("</t:").append(collectionName).append('>');
|
buffer.append("</t:").append(collectionName).append('>');
|
||||||
|
@ -53,9 +53,9 @@ public class TwoOperandExpression implements SearchExpression {
|
|||||||
buffer.append("<t:FieldURIOrConstant><t:Constant Value=\"");
|
buffer.append("<t:FieldURIOrConstant><t:Constant Value=\"");
|
||||||
// encode urlcompname
|
// encode urlcompname
|
||||||
if (fieldURI instanceof ExtendedFieldURI && "0x10f3".equals(((ExtendedFieldURI) fieldURI).propertyTag)) {
|
if (fieldURI instanceof ExtendedFieldURI && "0x10f3".equals(((ExtendedFieldURI) fieldURI).propertyTag)) {
|
||||||
buffer.append(StringUtil.xmlEncode(StringUtil.encodeUrlcompname(value)));
|
buffer.append(StringUtil.xmlEncodeAttribute(StringUtil.encodeUrlcompname(value)));
|
||||||
} else {
|
} else {
|
||||||
buffer.append(StringUtil.xmlEncode(value));
|
buffer.append(StringUtil.xmlEncodeAttribute(value));
|
||||||
}
|
}
|
||||||
buffer.append("\"/></t:FieldURIOrConstant>");
|
buffer.append("\"/></t:FieldURIOrConstant>");
|
||||||
|
|
||||||
|
@ -60,17 +60,17 @@ public class UnindexedFieldURI implements FieldURI {
|
|||||||
}
|
}
|
||||||
if ("MeetingTimeZone".equals(fieldName)) {
|
if ("MeetingTimeZone".equals(fieldName)) {
|
||||||
buffer.append("<t:MeetingTimeZone TimeZoneName=\"");
|
buffer.append("<t:MeetingTimeZone TimeZoneName=\"");
|
||||||
buffer.append(StringUtil.xmlEncode(value));
|
buffer.append(StringUtil.xmlEncodeAttribute(value));
|
||||||
buffer.append("\"></t:MeetingTimeZone>");
|
buffer.append("\"></t:MeetingTimeZone>");
|
||||||
} else if ("StartTimeZone".equals(fieldName)) {
|
} else if ("StartTimeZone".equals(fieldName)) {
|
||||||
buffer.append("<t:StartTimeZone Id=\"");
|
buffer.append("<t:StartTimeZone Id=\"");
|
||||||
buffer.append(StringUtil.xmlEncode(value));
|
buffer.append(StringUtil.xmlEncodeAttribute(value));
|
||||||
buffer.append("\"></t:StartTimeZone>");
|
buffer.append("\"></t:StartTimeZone>");
|
||||||
} else {
|
} else {
|
||||||
buffer.append("<t:");
|
buffer.append("<t:");
|
||||||
buffer.append(fieldName);
|
buffer.append(fieldName);
|
||||||
buffer.append('>');
|
buffer.append('>');
|
||||||
buffer.append(StringUtil.xmlEncode(value));
|
buffer.append(StringUtil.xmlEncodeAttribute(value));
|
||||||
buffer.append("</t:");
|
buffer.append("</t:");
|
||||||
buffer.append(fieldName);
|
buffer.append(fieldName);
|
||||||
buffer.append('>');
|
buffer.append('>');
|
||||||
|
@ -179,7 +179,7 @@ public final class StringUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Need to encode xml for iCal.
|
* Xml encode content.
|
||||||
*
|
*
|
||||||
* @param name decoded name
|
* @param name decoded name
|
||||||
* @return name encoded name
|
* @return name encoded name
|
||||||
@ -203,6 +203,22 @@ public final class StringUtil {
|
|||||||
return result;
|
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
|
* Need to decode xml for iCal
|
||||||
*
|
*
|
||||||
|
@ -475,7 +475,7 @@ public class TestExchangeSessionContact extends AbstractExchangeSessionTestCase
|
|||||||
vCardWriter.appendProperty("FN", "common name");
|
vCardWriter.appendProperty("FN", "common name");
|
||||||
vCardWriter.endCard();
|
vCardWriter.endCard();
|
||||||
|
|
||||||
itemName = "test {<:&'>+} accentué.vcf";
|
itemName = "test {<:&'>} \"accentué.vcf";
|
||||||
|
|
||||||
ExchangeSession.ItemResult result = session.createOrUpdateContact("testcontactfolder", itemName, vCardWriter.toString(), null, null);
|
ExchangeSession.ItemResult result = session.createOrUpdateContact("testcontactfolder", itemName, vCardWriter.toString(), null, null);
|
||||||
assertEquals(201, result.status);
|
assertEquals(201, result.status);
|
||||||
|
Loading…
Reference in New Issue
Block a user