mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 11:12:22 -05:00
Caldav: encode @ in path only for iCal 5 (OSX Lion)
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1754 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
c5c7b157c2
commit
7005f6dacd
@ -71,8 +71,12 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
ical_allowed_abs_path.clear('@');
|
ical_allowed_abs_path.clear('@');
|
||||||
}
|
}
|
||||||
|
|
||||||
static String encodePath(String path) throws URIException {
|
static String encodePath(CaldavRequest request, String path) throws URIException {
|
||||||
|
if (request.isIcal5()) {
|
||||||
return URIUtil.encode(path, ical_allowed_abs_path, "UTF-8");
|
return URIUtil.encode(path, ical_allowed_abs_path, "UTF-8");
|
||||||
|
} else {
|
||||||
|
return URIUtil.encodePath(path, "UTF-8");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -374,7 +378,7 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
|
|
||||||
protected void appendItemResponse(CaldavResponse response, CaldavRequest request, ExchangeSession.Item item) throws IOException {
|
protected void appendItemResponse(CaldavResponse response, CaldavRequest request, ExchangeSession.Item item) throws IOException {
|
||||||
StringBuilder eventPath = new StringBuilder();
|
StringBuilder eventPath = new StringBuilder();
|
||||||
eventPath.append(encodePath(request.getPath()));
|
eventPath.append(encodePath(request, request.getPath()));
|
||||||
if (!(eventPath.charAt(eventPath.length() - 1) == '/')) {
|
if (!(eventPath.charAt(eventPath.length() - 1) == '/')) {
|
||||||
eventPath.append('/');
|
eventPath.append('/');
|
||||||
}
|
}
|
||||||
@ -418,7 +422,7 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
* @throws IOException on error
|
* @throws IOException on error
|
||||||
*/
|
*/
|
||||||
public void appendFolderOrItem(CaldavResponse response, CaldavRequest request, ExchangeSession.Folder folder, String subFolder) throws IOException {
|
public void appendFolderOrItem(CaldavResponse response, CaldavRequest request, ExchangeSession.Folder folder, String subFolder) throws IOException {
|
||||||
response.startResponse(encodePath(request.getPath(subFolder)));
|
response.startResponse(encodePath(request, request.getPath(subFolder)));
|
||||||
response.startPropstat();
|
response.startPropstat();
|
||||||
|
|
||||||
if (request.hasProperty("resourcetype")) {
|
if (request.hasProperty("resourcetype")) {
|
||||||
@ -503,7 +507,7 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
DavGatewayTray.debug(new BundleMessage("LOG_ACCESS_FORBIDDEN", folderPath, e.getMessage()));
|
DavGatewayTray.debug(new BundleMessage("LOG_ACCESS_FORBIDDEN", folderPath, e.getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
response.startResponse(encodePath(request.getPath(subFolder)));
|
response.startResponse(encodePath(request, request.getPath(subFolder)));
|
||||||
response.startPropstat();
|
response.startPropstat();
|
||||||
|
|
||||||
if (request.hasProperty("resourcetype")) {
|
if (request.hasProperty("resourcetype")) {
|
||||||
@ -535,7 +539,7 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
* @throws IOException on error
|
* @throws IOException on error
|
||||||
*/
|
*/
|
||||||
public void appendOutbox(CaldavResponse response, CaldavRequest request, String subFolder) throws IOException {
|
public void appendOutbox(CaldavResponse response, CaldavRequest request, String subFolder) throws IOException {
|
||||||
response.startResponse(encodePath(request.getPath(subFolder)));
|
response.startResponse(encodePath(request, request.getPath(subFolder)));
|
||||||
response.startPropstat();
|
response.startPropstat();
|
||||||
|
|
||||||
if (request.hasProperty("resourcetype")) {
|
if (request.hasProperty("resourcetype")) {
|
||||||
@ -754,7 +758,7 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
|
|
||||||
// send not found events errors
|
// send not found events errors
|
||||||
for (String href : notFound) {
|
for (String href : notFound) {
|
||||||
response.startResponse(encodePath(href));
|
response.startResponse(encodePath(request, href));
|
||||||
response.appendPropstatNotFound();
|
response.appendPropstatNotFound();
|
||||||
response.endResponse();
|
response.endResponse();
|
||||||
}
|
}
|
||||||
@ -771,11 +775,11 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
public void sendPrincipalsFolder(CaldavRequest request) throws IOException {
|
public void sendPrincipalsFolder(CaldavRequest request) throws IOException {
|
||||||
CaldavResponse response = new CaldavResponse(HttpStatus.SC_MULTI_STATUS);
|
CaldavResponse response = new CaldavResponse(HttpStatus.SC_MULTI_STATUS);
|
||||||
response.startMultistatus();
|
response.startMultistatus();
|
||||||
response.startResponse(encodePath(request.getPath()));
|
response.startResponse(encodePath(request, request.getPath()));
|
||||||
response.startPropstat();
|
response.startPropstat();
|
||||||
|
|
||||||
if (request.hasProperty("current-user-principal")) {
|
if (request.hasProperty("current-user-principal")) {
|
||||||
response.appendHrefProperty("D:current-user-principal", encodePath("/principals/users/" + session.getEmail()));
|
response.appendHrefProperty("D:current-user-principal", encodePath(request, "/principals/users/" + session.getEmail()));
|
||||||
}
|
}
|
||||||
response.endPropStatOK();
|
response.endPropStatOK();
|
||||||
response.endResponse();
|
response.endResponse();
|
||||||
@ -792,7 +796,7 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
public void sendUserRoot(CaldavRequest request) throws IOException {
|
public void sendUserRoot(CaldavRequest request) throws IOException {
|
||||||
CaldavResponse response = new CaldavResponse(HttpStatus.SC_MULTI_STATUS);
|
CaldavResponse response = new CaldavResponse(HttpStatus.SC_MULTI_STATUS);
|
||||||
response.startMultistatus();
|
response.startMultistatus();
|
||||||
response.startResponse(encodePath(request.getPath()));
|
response.startResponse(encodePath(request, request.getPath()));
|
||||||
response.startPropstat();
|
response.startPropstat();
|
||||||
|
|
||||||
if (request.hasProperty("resourcetype")) {
|
if (request.hasProperty("resourcetype")) {
|
||||||
@ -840,7 +844,7 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
response.appendProperty("D:resourcetype", "<D:collection/>");
|
response.appendProperty("D:resourcetype", "<D:collection/>");
|
||||||
}
|
}
|
||||||
if (request.hasProperty("current-user-principal")) {
|
if (request.hasProperty("current-user-principal")) {
|
||||||
response.appendHrefProperty("D:current-user-principal", encodePath("/principals/users/" + session.getEmail()));
|
response.appendHrefProperty("D:current-user-principal", encodePath(request, "/principals/users/" + session.getEmail()));
|
||||||
}
|
}
|
||||||
response.endPropStatOK();
|
response.endPropStatOK();
|
||||||
response.endResponse();
|
response.endResponse();
|
||||||
@ -936,18 +940,18 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
|
|
||||||
CaldavResponse response = new CaldavResponse(HttpStatus.SC_MULTI_STATUS);
|
CaldavResponse response = new CaldavResponse(HttpStatus.SC_MULTI_STATUS);
|
||||||
response.startMultistatus();
|
response.startMultistatus();
|
||||||
response.startResponse(encodePath("/principals/" + prefix + '/' + principal));
|
response.startResponse(encodePath(request, "/principals/" + prefix + '/' + principal));
|
||||||
response.startPropstat();
|
response.startPropstat();
|
||||||
|
|
||||||
if (request.hasProperty("principal-URL")) {
|
if (request.hasProperty("principal-URL")) {
|
||||||
response.appendHrefProperty("D:principal-URL", encodePath("/principals/" + prefix + '/' + principal));
|
response.appendHrefProperty("D:principal-URL", encodePath(request, "/principals/" + prefix + '/' + principal));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.hasProperty("calendar-home-set")) {
|
if (request.hasProperty("calendar-home-set")) {
|
||||||
if ("users".equals(prefix)) {
|
if ("users".equals(prefix)) {
|
||||||
response.appendHrefProperty("C:calendar-home-set", encodePath("/users/" + actualPrincipal + "/calendar/"));
|
response.appendHrefProperty("C:calendar-home-set", encodePath(request, "/users/" + actualPrincipal + "/calendar/"));
|
||||||
} else {
|
} else {
|
||||||
response.appendHrefProperty("C:calendar-home-set", encodePath('/' + prefix + '/' + actualPrincipal));
|
response.appendHrefProperty("C:calendar-home-set", encodePath(request, '/' + prefix + '/' + actualPrincipal));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -957,19 +961,19 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
|
|
||||||
if (request.hasProperty("addressbook-home-set") && "users".equals(prefix)) {
|
if (request.hasProperty("addressbook-home-set") && "users".equals(prefix)) {
|
||||||
if (request.isUserAgent("Address%20Book") || request.isUserAgent("Darwin")) {
|
if (request.isUserAgent("Address%20Book") || request.isUserAgent("Darwin")) {
|
||||||
response.appendHrefProperty("E:addressbook-home-set", encodePath("/users/" + actualPrincipal + '/'));
|
response.appendHrefProperty("E:addressbook-home-set", encodePath(request, "/users/" + actualPrincipal + '/'));
|
||||||
} else {
|
} else {
|
||||||
response.appendHrefProperty("E:addressbook-home-set", encodePath("/users/" + actualPrincipal + "/contacts/"));
|
response.appendHrefProperty("E:addressbook-home-set", encodePath(request, "/users/" + actualPrincipal + "/contacts/"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("users".equals(prefix)) {
|
if ("users".equals(prefix)) {
|
||||||
if (request.hasProperty("schedule-inbox-URL")) {
|
if (request.hasProperty("schedule-inbox-URL")) {
|
||||||
response.appendHrefProperty("C:schedule-inbox-URL", encodePath("/users/" + actualPrincipal + "/inbox/"));
|
response.appendHrefProperty("C:schedule-inbox-URL", encodePath(request, "/users/" + actualPrincipal + "/inbox/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.hasProperty("schedule-outbox-URL")) {
|
if (request.hasProperty("schedule-outbox-URL")) {
|
||||||
response.appendHrefProperty("C:schedule-outbox-URL", encodePath("/users/" + actualPrincipal + "/outbox/"));
|
response.appendHrefProperty("C:schedule-outbox-URL", encodePath(request, "/users/" + actualPrincipal + "/outbox/"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// public calendar, send root href as inbox url (always empty) for Lightning
|
// public calendar, send root href as inbox url (always empty) for Lightning
|
||||||
@ -978,7 +982,7 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
}
|
}
|
||||||
// send user outbox
|
// send user outbox
|
||||||
if (request.hasProperty("schedule-outbox-URL")) {
|
if (request.hasProperty("schedule-outbox-URL")) {
|
||||||
response.appendHrefProperty("C:schedule-outbox-URL", encodePath("/users/" + session.getEmail() + "/outbox/"));
|
response.appendHrefProperty("C:schedule-outbox-URL", encodePath(request, "/users/" + session.getEmail() + "/outbox/"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1409,6 +1413,10 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
return isUserAgent("Lightning/");
|
return isUserAgent("Lightning/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean isIcal5() {
|
||||||
|
return isUserAgent("CoreDAV/");
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean isUserAgent(String key) {
|
protected boolean isUserAgent(String key) {
|
||||||
String userAgent = headers.get("user-agent");
|
String userAgent = headers.get("user-agent");
|
||||||
return userAgent != null && userAgent.indexOf(key) >= 0;
|
return userAgent != null && userAgent.indexOf(key) >= 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user