1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-08-13 16:53:51 -04:00

Caldav: another special characters handling improvement

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@503 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-04-03 23:01:18 +00:00
parent d72e185213
commit acebab6e84
2 changed files with 13 additions and 12 deletions

View File

@ -246,7 +246,7 @@ public class CaldavConnection extends AbstractConnection {
} else if ("PUT".equals(command) && "users".equals(paths[1]) && paths.length == 5 && "calendar".equals(paths[3])) {
String etag = headers.get("if-match");
String noneMatch = headers.get("if-none-match");
ExchangeSession.EventResult eventResult = session.createOrUpdateEvent(paths[2], xmlDecodeName(paths[4]), body, etag, noneMatch);
ExchangeSession.EventResult eventResult = session.createOrUpdateEvent(paths[2], xmlDecodeName(URIUtil.decode(paths[4])), body, etag, noneMatch);
if (eventResult.etag != null) {
HashMap<String, String> responseHeaders = new HashMap<String, String>();
responseHeaders.put("ETag", eventResult.etag);
@ -259,12 +259,12 @@ public class CaldavConnection extends AbstractConnection {
if ("inbox".equals(paths[3])) {
paths[3] = "INBOX";
}
int status = session.deleteEvent(paths[2], paths[3], xmlEncodeName(paths[4]));
int status = session.deleteEvent(paths[2], paths[3], xmlDecodeName(URIUtil.decode(paths[4])));
sendHttpResponse(status);
} else if ("GET".equals(command) && "users".equals(paths[1]) && paths.length == 5 && "calendar".equals(paths[3])
// only current user for now
&& session.getEmail().equalsIgnoreCase(paths[2])) {
ExchangeSession.Event event = session.getEvent(paths[2], paths[3], paths[4]);
ExchangeSession.Event event = session.getEvent(paths[2], paths[3], xmlDecodeName(URIUtil.decode(paths[4])));
sendHttpResponse(HttpStatus.SC_OK, null, "text/calendar;charset=UTF-8", event.getICS(), true);
} else {
@ -460,6 +460,7 @@ public class CaldavConnection extends AbstractConnection {
appendEventResponse(response, request, path, session.getEvent(principal, path, eventName));
}
} catch (HttpException e) {
DavGatewayTray.warn("Event not found:"+href);
notFound.add(href);
}
}
@ -761,10 +762,10 @@ public class CaldavConnection extends AbstractConnection {
result = result.replaceAll("&", "&amp;");
}
if (name.indexOf('<') >= 0) {
result = result.replaceAll("<", "#lt#");
result = result.replaceAll("<", "&lt;");
}
if (name.indexOf('>') >= 0) {
result = result.replaceAll(">", "#gt#");
result = result.replaceAll(">", "&gt;");
}
return result;
}
@ -780,11 +781,11 @@ public class CaldavConnection extends AbstractConnection {
if (name.indexOf("&amp;") >= 0) {
result = result.replaceAll("&amp;", "&");
}
if (name.indexOf("#gt#") >= 0) {
result = result.replaceAll("#gt#", ">");
if (name.indexOf("&gt;") >= 0) {
result = result.replaceAll("&gt;", ">");
}
if (name.indexOf("#lt#") >= 0) {
result = result.replaceAll("#lt#", "<");
if (name.indexOf("&lt;") >= 0) {
result = result.replaceAll("&lt;", "<");
}
return result;
}

View File

@ -1414,7 +1414,7 @@ public class ExchangeSession {
}
public EventResult createOrUpdateEvent(String principal, String path, String icsBody, String etag, String noneMatch) throws IOException {
String messageUrl = URIUtil.encodePathQuery(replacePrincipal(calendarUrl, principal) + "/" + URIUtil.decode(path));
String messageUrl = URIUtil.encodePathQuery(replacePrincipal(calendarUrl, principal) + "/" + path);
return internalCreateOrUpdateEvent(messageUrl, "urn:content-classes:appointment", icsBody, etag, noneMatch);
}
@ -1613,12 +1613,12 @@ public class ExchangeSession {
ArrayList<DavProperty> list = new ArrayList<DavProperty>();
list.add(new DefaultDavProperty(DavPropertyName.create("schedule-state", Namespace.getNamespace("CALDAV:")), "CALDAV:schedule-processed"));
list.add(new DefaultDavProperty(DavPropertyName.create("read", URN_SCHEMAS_HTTPMAIL), "1"));
PropPatchMethod patchMethod = new PropPatchMethod(URIUtil.encodePath(replacePrincipal(getFolderPath(URIUtil.decode(path)), principal)) + "/" + eventName, list);
PropPatchMethod patchMethod = new PropPatchMethod(URIUtil.encodePath(replacePrincipal(getFolderPath(URIUtil.decode(path)), principal) + "/" + eventName), list);
DavGatewayHttpClientFacade.executeMethod(httpClient, patchMethod);
status = HttpStatus.SC_OK;
} else {
status = DavGatewayHttpClientFacade.executeDeleteMethod(httpClient,
URIUtil.encodePath(replacePrincipal(getFolderPath(URIUtil.decode(path)), principal)) + "/" + eventName);
URIUtil.encodePath(replacePrincipal(getFolderPath(URIUtil.decode(path)), principal) + "/" + eventName));
}
return status;
}