Carddav: fix regression on address book handling on Snow Leopard

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1891 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2012-02-01 23:10:23 +00:00
parent 0c4454a9fc
commit 243ac71497
1 changed files with 14 additions and 6 deletions

View File

@ -974,13 +974,11 @@ public class CaldavConnection extends AbstractConnection {
if (request.hasProperty("addressbook-home-set")) {
if (request.isUserAgent("Address%20Book") || request.isUserAgent("Darwin")) {
if ("users".equals(prefix)) {
response.appendHrefProperty("E:addressbook-home-set", encodePath(request, "/users/" + actualPrincipal + '/'));
} else {
response.appendHrefProperty("E:addressbook-home-set", encodePath(request, '/' + prefix + '/' + principal + '/'));
}
response.appendHrefProperty("E:addressbook-home-set", encodePath(request, '/' + prefix + '/' + actualPrincipal + '/'));
} else if ("users".equals(prefix)) {
response.appendHrefProperty("E:addressbook-home-set", encodePath(request, "/users/" + actualPrincipal + "/contacts/"));
} else {
response.appendHrefProperty("E:addressbook-home-set", encodePath(request, '/' + prefix + '/' + actualPrincipal + '/'));
}
}
@ -1618,7 +1616,17 @@ public class CaldavConnection extends AbstractConnection {
* Here we replace the ___ in the path with spaces. Be warned if your actual address book path has ___
* it'll fail.
*/
return calendarPath.toString().replaceAll("___", " ").replaceAll("/addressbook", "");
String result = calendarPath.toString();
// replace unsupported spaces
if (result.indexOf(' ') >=0 ) {
result = result.replaceAll("___", " ");
}
// replace /addressbook suffix on public folders
if (result.startsWith("/public")) {
result = result.replaceAll("/addressbook", "");
}
return result;
} else {
return calendarPath.toString();
}