1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 03:02:22 -05:00

URL encode hrefs in Caldav response, maybe the reason for iCal failure

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@316 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-02-03 15:30:11 +00:00
parent 5e409645ef
commit ebac6850dc

View File

@ -7,6 +7,7 @@ import davmail.exchange.ExchangeSessionFactory;
import davmail.tray.DavGatewayTray; import davmail.tray.DavGatewayTray;
import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.util.URIUtil;
import org.apache.commons.httpclient.auth.AuthenticationException; import org.apache.commons.httpclient.auth.AuthenticationException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -256,7 +257,7 @@ public class CaldavConnection extends AbstractConnection {
protected void appendEventResponse(StringBuilder buffer, CaldavRequest request, ExchangeSession.Event event) throws IOException { protected void appendEventResponse(StringBuilder buffer, CaldavRequest request, ExchangeSession.Event event) throws IOException {
String eventPath = event.getPath().replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;"); String eventPath = event.getPath().replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
buffer.append("<D:response>"); buffer.append("<D:response>");
buffer.append("<D:href>/users/").append(session.getEmail()).append("/calendar").append(eventPath).append("</D:href>"); buffer.append("<D:href>/users/").append(session.getEmail()).append("/calendar").append(URIUtil.encodePath(eventPath)).append("</D:href>");
buffer.append("<D:propstat>"); buffer.append("<D:propstat>");
buffer.append("<D:prop>"); buffer.append("<D:prop>");
if (request.hasProperty("calendar-data")) { if (request.hasProperty("calendar-data")) {
@ -459,7 +460,7 @@ public class CaldavConnection extends AbstractConnection {
// send not found events errors // send not found events errors
for (String href : notFound) { for (String href : notFound) {
buffer.append("<D:response>"); buffer.append("<D:response>");
buffer.append("<D:href>").append(href).append("</D:href>"); buffer.append("<D:href>").append(URIUtil.encodePath(href)).append("</D:href>");
buffer.append("<D:propstat>"); buffer.append("<D:propstat>");
buffer.append("<D:status>HTTP/1.1 404 Not Found</D:status>"); buffer.append("<D:status>HTTP/1.1 404 Not Found</D:status>");
buffer.append("</D:propstat>"); buffer.append("</D:propstat>");
@ -769,7 +770,7 @@ public class CaldavConnection extends AbstractConnection {
if (hrefs == null) { if (hrefs == null) {
hrefs = new HashSet<String>(); hrefs = new HashSet<String>();
} }
hrefs.add(streamReader.getText()); hrefs.add(URIUtil.decode(streamReader.getText()));
} }
inElement = false; inElement = false;
} }