From acebab6e84aa71f5b117d7fa1de00068607e0599 Mon Sep 17 00:00:00 2001 From: mguessan Date: Fri, 3 Apr 2009 23:01:18 +0000 Subject: [PATCH] Caldav: another special characters handling improvement git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@503 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- src/java/davmail/caldav/CaldavConnection.java | 19 ++++++++++--------- .../davmail/exchange/ExchangeSession.java | 6 +++--- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/java/davmail/caldav/CaldavConnection.java b/src/java/davmail/caldav/CaldavConnection.java index 7f312e7c..72e2c54f 100644 --- a/src/java/davmail/caldav/CaldavConnection.java +++ b/src/java/davmail/caldav/CaldavConnection.java @@ -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 responseHeaders = new HashMap(); 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("&", "&"); } if (name.indexOf('<') >= 0) { - result = result.replaceAll("<", "#lt#"); + result = result.replaceAll("<", "<"); } if (name.indexOf('>') >= 0) { - result = result.replaceAll(">", "#gt#"); + result = result.replaceAll(">", ">"); } return result; } @@ -780,11 +781,11 @@ public class CaldavConnection extends AbstractConnection { if (name.indexOf("&") >= 0) { result = result.replaceAll("&", "&"); } - if (name.indexOf("#gt#") >= 0) { - result = result.replaceAll("#gt#", ">"); + if (name.indexOf(">") >= 0) { + result = result.replaceAll(">", ">"); } - if (name.indexOf("#lt#") >= 0) { - result = result.replaceAll("#lt#", "<"); + if (name.indexOf("<") >= 0) { + result = result.replaceAll("<", "<"); } return result; } diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index 86ffe77b..95d7740a 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -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 list = new ArrayList(); 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; }