1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-14 19:52:21 -05:00

Caldav: fix bug 2833044 Event not found error on dismissing reminders with events created in Outlook with a plus sign in subject

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@649 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-08-06 12:15:52 +00:00
parent b86da04306
commit 0515fca2b6

View File

@ -143,11 +143,7 @@ public class CaldavConnection extends AbstractConnection {
tokens = new StringTokenizer(line); tokens = new StringTokenizer(line);
String command = tokens.nextToken(); String command = tokens.nextToken();
Map<String, String> headers = parseHeaders(); Map<String, String> headers = parseHeaders();
String encodedPath = tokens.nextToken(); String encodedPath = encodePlusSign(tokens.nextToken());
// make sure + sign in URL is encoded
if (encodedPath.indexOf('+') >= 0) {
encodedPath = encodedPath.replaceAll("\\+", "%2B");
}
String path = URIUtil.decode(encodedPath); String path = URIUtil.decode(encodedPath);
String content = getContent(headers.get("content-length")); String content = getContent(headers.get("content-length"));
setSocketTimeout(headers.get("keep-alive")); setSocketTimeout(headers.get("keep-alive"));
@ -236,7 +232,7 @@ public class CaldavConnection extends AbstractConnection {
} }
} else if (request.isPath(2, "public")) { } else if (request.isPath(2, "public")) {
StringBuilder prefixBuffer = new StringBuilder("public"); StringBuilder prefixBuffer = new StringBuilder("public");
for (int i=3; i<request.getPathLength()-1;i++) { for (int i = 3; i < request.getPathLength() - 1; i++) {
prefixBuffer.append('/').append(request.getPathElement(i)); prefixBuffer.append('/').append(request.getPathElement(i));
} }
sendPrincipal(request, prefixBuffer.toString(), request.getLastPath()); sendPrincipal(request, prefixBuffer.toString(), request.getLastPath());
@ -935,7 +931,7 @@ public class CaldavConnection extends AbstractConnection {
public void sendHttpResponse(int status, Map<String, String> headers, String contentType, byte[] content, boolean keepAlive) throws IOException { public void sendHttpResponse(int status, Map<String, String> headers, String contentType, byte[] content, boolean keepAlive) throws IOException {
sendClient("HTTP/1.1 " + status + ' ' + HttpStatus.getStatusText(status)); sendClient("HTTP/1.1 " + status + ' ' + HttpStatus.getStatusText(status));
String version = DavGateway.getCurrentVersion(); String version = DavGateway.getCurrentVersion();
sendClient("Server: DavMail Gateway "+ (version==null?"":version)); sendClient("Server: DavMail Gateway " + (version == null ? "" : version));
sendClient("DAV: 1, calendar-access, calendar-schedule, calendarserver-private-events, calendar-proxy"); sendClient("DAV: 1, calendar-access, calendar-schedule, calendarserver-private-events, calendar-proxy");
SimpleDateFormat formatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.ENGLISH); SimpleDateFormat formatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.ENGLISH);
String now = formatter.format(new Date()); String now = formatter.format(new Date());
@ -1035,6 +1031,20 @@ public class CaldavConnection extends AbstractConnection {
return result; return result;
} }
/**
* Make sure + sign in URL is encoded.
* @param path URL path
* @return reencoded path
*/
protected String encodePlusSign(String path) {
// make sure + sign in URL is encoded
if (path.indexOf('+') >= 0) {
return path.replaceAll("\\+", "%2B");
} else {
return path;
}
}
protected class CaldavRequest { protected class CaldavRequest {
protected final String command; protected final String command;
protected final String path; protected final String path;
@ -1211,7 +1221,7 @@ public class CaldavConnection extends AbstractConnection {
if (isIcal()) { if (isIcal()) {
hrefs.add(streamReader.getText()); hrefs.add(streamReader.getText());
} else { } else {
hrefs.add(URIUtil.decode(streamReader.getText())); hrefs.add(URIUtil.decode(encodePlusSign(streamReader.getText())));
} }
} }
inElement = false; inElement = false;