mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-05 18:58:02 -05:00
Caldav: force @ encode to %40 for iCal 5
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1745 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
7a31659473
commit
e2aadf235d
@ -34,6 +34,8 @@ import davmail.ui.tray.DavGatewayTray;
|
|||||||
import davmail.util.StringUtil;
|
import davmail.util.StringUtil;
|
||||||
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.URI;
|
||||||
|
import org.apache.commons.httpclient.URIException;
|
||||||
import org.apache.commons.httpclient.util.URIUtil;
|
import org.apache.commons.httpclient.util.URIUtil;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
@ -60,6 +62,19 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
|
|
||||||
protected boolean closed;
|
protected boolean closed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* custom url encode path set for iCal 5
|
||||||
|
*/
|
||||||
|
public static final BitSet ical_allowed_abs_path = new BitSet(256);
|
||||||
|
static {
|
||||||
|
ical_allowed_abs_path.or(URI.allowed_abs_path);
|
||||||
|
ical_allowed_abs_path.clear('@');
|
||||||
|
}
|
||||||
|
|
||||||
|
static String encodePath(String path) throws URIException {
|
||||||
|
return URIUtil.encode(path, ical_allowed_abs_path, "UTF-8");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the streams and start the thread.
|
* Initialize the streams and start the thread.
|
||||||
*
|
*
|
||||||
@ -359,7 +374,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(URIUtil.encodePath(request.getPath()));
|
eventPath.append(encodePath(request.getPath()));
|
||||||
if (!(eventPath.charAt(eventPath.length() - 1) == '/')) {
|
if (!(eventPath.charAt(eventPath.length() - 1) == '/')) {
|
||||||
eventPath.append('/');
|
eventPath.append('/');
|
||||||
}
|
}
|
||||||
@ -403,7 +418,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(URIUtil.encodePath(request.getPath(subFolder)));
|
response.startResponse(encodePath(request.getPath(subFolder)));
|
||||||
response.startPropstat();
|
response.startPropstat();
|
||||||
|
|
||||||
if (request.hasProperty("resourcetype")) {
|
if (request.hasProperty("resourcetype")) {
|
||||||
@ -488,7 +503,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(URIUtil.encodePath(request.getPath(subFolder)));
|
response.startResponse(encodePath(request.getPath(subFolder)));
|
||||||
response.startPropstat();
|
response.startPropstat();
|
||||||
|
|
||||||
if (request.hasProperty("resourcetype")) {
|
if (request.hasProperty("resourcetype")) {
|
||||||
@ -520,7 +535,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(URIUtil.encodePath(request.getPath(subFolder)));
|
response.startResponse(encodePath(request.getPath(subFolder)));
|
||||||
response.startPropstat();
|
response.startPropstat();
|
||||||
|
|
||||||
if (request.hasProperty("resourcetype")) {
|
if (request.hasProperty("resourcetype")) {
|
||||||
@ -739,7 +754,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(URIUtil.encodePath(href));
|
response.startResponse(encodePath(href));
|
||||||
response.appendPropstatNotFound();
|
response.appendPropstatNotFound();
|
||||||
response.endResponse();
|
response.endResponse();
|
||||||
}
|
}
|
||||||
@ -756,7 +771,7 @@ 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(URIUtil.encodePath(request.getPath()));
|
response.startResponse(encodePath(request.getPath()));
|
||||||
response.startPropstat();
|
response.startPropstat();
|
||||||
|
|
||||||
if (request.hasProperty("current-user-principal")) {
|
if (request.hasProperty("current-user-principal")) {
|
||||||
@ -777,7 +792,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(URIUtil.encodePath(request.getPath()));
|
response.startResponse(encodePath(request.getPath()));
|
||||||
response.startPropstat();
|
response.startPropstat();
|
||||||
|
|
||||||
if (request.hasProperty("resourcetype")) {
|
if (request.hasProperty("resourcetype")) {
|
||||||
@ -921,7 +936,7 @@ 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(URIUtil.encodePath("/principals/" + prefix + '/' + principal));
|
response.startResponse(encodePath("/principals/" + prefix + '/' + principal));
|
||||||
response.startPropstat();
|
response.startPropstat();
|
||||||
|
|
||||||
if (request.hasProperty("principal-URL")) {
|
if (request.hasProperty("principal-URL")) {
|
||||||
@ -1658,9 +1673,8 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void appendHrefProperty(String propertyName, String propertyValue) throws IOException {
|
public void appendHrefProperty(String propertyName, String propertyValue) throws IOException {
|
||||||
appendProperty(propertyName, null, "<D:href>" + URIUtil.encodePath(StringUtil.xmlEncode(propertyValue)) + "</D:href>");
|
appendProperty(propertyName, null, "<D:href>" + encodePath(StringUtil.xmlEncode(propertyValue)) + "</D:href>");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void appendProperty(String propertyName) throws IOException {
|
public void appendProperty(String propertyName) throws IOException {
|
||||||
|
Loading…
Reference in New Issue
Block a user