mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-07 03:38:05 -05:00
Dav: decode permanenturl to avoid double urlencoding issue
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1942 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
75cec9987b
commit
104f64f86e
@ -1095,7 +1095,7 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
public Contact(MultiStatusResponse multiStatusResponse) throws URIException, DavMailException {
|
public Contact(MultiStatusResponse multiStatusResponse) throws URIException, DavMailException {
|
||||||
setHref(URIUtil.decode(multiStatusResponse.getHref()));
|
setHref(URIUtil.decode(multiStatusResponse.getHref()));
|
||||||
DavPropertySet properties = multiStatusResponse.getProperties(HttpStatus.SC_OK);
|
DavPropertySet properties = multiStatusResponse.getProperties(HttpStatus.SC_OK);
|
||||||
permanentUrl = getPropertyIfExists(properties, "permanenturl");
|
permanentUrl = getURLPropertyIfExists(properties, "permanenturl");
|
||||||
etag = getPropertyIfExists(properties, "etag");
|
etag = getPropertyIfExists(properties, "etag");
|
||||||
displayName = getPropertyIfExists(properties, "displayname");
|
displayName = getPropertyIfExists(properties, "displayname");
|
||||||
for (String attributeName : CONTACT_ATTRIBUTES) {
|
for (String attributeName : CONTACT_ATTRIBUTES) {
|
||||||
@ -1286,7 +1286,7 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
public Event(MultiStatusResponse multiStatusResponse) throws URIException {
|
public Event(MultiStatusResponse multiStatusResponse) throws URIException {
|
||||||
setHref(URIUtil.decode(multiStatusResponse.getHref()));
|
setHref(URIUtil.decode(multiStatusResponse.getHref()));
|
||||||
DavPropertySet properties = multiStatusResponse.getProperties(HttpStatus.SC_OK);
|
DavPropertySet properties = multiStatusResponse.getProperties(HttpStatus.SC_OK);
|
||||||
permanentUrl = getPropertyIfExists(properties, "permanenturl");
|
permanentUrl = getURLPropertyIfExists(properties, "permanenturl");
|
||||||
etag = getPropertyIfExists(properties, "etag");
|
etag = getPropertyIfExists(properties, "etag");
|
||||||
displayName = getPropertyIfExists(properties, "displayname");
|
displayName = getPropertyIfExists(properties, "displayname");
|
||||||
subject = getPropertyIfExists(properties, "subject");
|
subject = getPropertyIfExists(properties, "subject");
|
||||||
@ -1559,7 +1559,7 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
if (Settings.getBooleanProperty("davmail.deleteBroken")) {
|
if (Settings.getBooleanProperty("davmail.deleteBroken")) {
|
||||||
LOGGER.warn("Deleting broken event at: " + permanentUrl);
|
LOGGER.warn("Deleting broken event at: " + permanentUrl);
|
||||||
try {
|
try {
|
||||||
DavGatewayHttpClientFacade.executeDeleteMethod(httpClient, permanentUrl);
|
DavGatewayHttpClientFacade.executeDeleteMethod(httpClient, encodeAndFixUrl(permanentUrl));
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
LOGGER.warn("Unable to delete broken event at: " + permanentUrl);
|
LOGGER.warn("Unable to delete broken event at: " + permanentUrl);
|
||||||
}
|
}
|
||||||
@ -1939,6 +1939,14 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getURLPropertyIfExists(DavPropertySet properties, String alias) throws URIException {
|
||||||
|
String result = getPropertyIfExists(properties, alias);
|
||||||
|
if (result != null) {
|
||||||
|
result = URIUtil.decode(result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
protected int getIntPropertyIfExists(DavPropertySet properties, String alias) {
|
protected int getIntPropertyIfExists(DavPropertySet properties, String alias) {
|
||||||
DavProperty property = properties.get(Field.getPropertyName(alias));
|
DavProperty property = properties.get(Field.getPropertyName(alias));
|
||||||
if (property == null) {
|
if (property == null) {
|
||||||
@ -1985,7 +1993,7 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
message.messageUrl = URIUtil.decode(responseEntity.getHref());
|
message.messageUrl = URIUtil.decode(responseEntity.getHref());
|
||||||
DavPropertySet properties = responseEntity.getProperties(HttpStatus.SC_OK);
|
DavPropertySet properties = responseEntity.getProperties(HttpStatus.SC_OK);
|
||||||
|
|
||||||
message.permanentUrl = getPropertyIfExists(properties, "permanenturl");
|
message.permanentUrl = getURLPropertyIfExists(properties, "permanenturl");
|
||||||
message.size = getIntPropertyIfExists(properties, "messageSize");
|
message.size = getIntPropertyIfExists(properties, "messageSize");
|
||||||
message.uid = getPropertyIfExists(properties, "uid");
|
message.uid = getPropertyIfExists(properties, "uid");
|
||||||
message.imapUid = getLongPropertyIfExists(properties, "imapUid");
|
message.imapUid = getLongPropertyIfExists(properties, "imapUid");
|
||||||
@ -2201,7 +2209,7 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
List<ExchangeSession.Event> events = getAllEvents(folderPath);
|
List<ExchangeSession.Event> events = getAllEvents(folderPath);
|
||||||
for (ExchangeSession.Event event : events) {
|
for (ExchangeSession.Event event : events) {
|
||||||
if (itemName.equals(event.getName())) {
|
if (itemName.equals(event.getName())) {
|
||||||
responses = DavGatewayHttpClientFacade.executePropFindMethod(httpClient, ((DavExchangeSession.Event) event).getPermanentUrl(), 0, EVENT_REQUEST_PROPERTIES_NAME_SET);
|
responses = DavGatewayHttpClientFacade.executePropFindMethod(httpClient, encodeAndFixUrl(((DavExchangeSession.Event) event).getPermanentUrl()), 0, EVENT_REQUEST_PROPERTIES_NAME_SET);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2629,7 +2637,7 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void updateMessage(ExchangeSession.Message message, Map<String, String> properties) throws IOException {
|
public void updateMessage(ExchangeSession.Message message, Map<String, String> properties) throws IOException {
|
||||||
PropPatchMethod patchMethod = new PropPatchMethod(message.permanentUrl, buildProperties(properties)) {
|
PropPatchMethod patchMethod = new PropPatchMethod(encodeAndFixUrl(message.permanentUrl), buildProperties(properties)) {
|
||||||
@Override
|
@Override
|
||||||
protected void processResponseBody(HttpState httpState, HttpConnection httpConnection) {
|
protected void processResponseBody(HttpState httpState, HttpConnection httpConnection) {
|
||||||
// ignore response body, sometimes invalid with exchange mapi properties
|
// ignore response body, sometimes invalid with exchange mapi properties
|
||||||
@ -2652,7 +2660,7 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
@Override
|
@Override
|
||||||
public void deleteMessage(ExchangeSession.Message message) throws IOException {
|
public void deleteMessage(ExchangeSession.Message message) throws IOException {
|
||||||
LOGGER.debug("Delete " + message.permanentUrl + " (" + message.messageUrl + ')');
|
LOGGER.debug("Delete " + message.permanentUrl + " (" + message.messageUrl + ')');
|
||||||
DavGatewayHttpClientFacade.executeDeleteMethod(httpClient, message.permanentUrl);
|
DavGatewayHttpClientFacade.executeDeleteMethod(httpClient, encodeAndFixUrl(message.permanentUrl));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2754,7 +2762,7 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
messageProperties.add(Field.getPropertyName("date"));
|
messageProperties.add(Field.getPropertyName("date"));
|
||||||
messageProperties.add(Field.getPropertyName("htmldescription"));
|
messageProperties.add(Field.getPropertyName("htmldescription"));
|
||||||
messageProperties.add(Field.getPropertyName("body"));
|
messageProperties.add(Field.getPropertyName("body"));
|
||||||
PropFindMethod propFindMethod = new PropFindMethod(URIUtil.encodePath(message.permanentUrl), messageProperties, 0);
|
PropFindMethod propFindMethod = new PropFindMethod(encodeAndFixUrl(message.permanentUrl), messageProperties, 0);
|
||||||
DavGatewayHttpClientFacade.executeMethod(httpClient, propFindMethod);
|
DavGatewayHttpClientFacade.executeMethod(httpClient, propFindMethod);
|
||||||
MultiStatus responses = propFindMethod.getResponseBodyAsMultiStatus();
|
MultiStatus responses = propFindMethod.getResponseBodyAsMultiStatus();
|
||||||
if (responses.getResponses().length > 0) {
|
if (responses.getResponses().length > 0) {
|
||||||
@ -2950,7 +2958,7 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
protected void moveToTrash(ExchangeSession.Message message) throws IOException {
|
protected void moveToTrash(ExchangeSession.Message message) throws IOException {
|
||||||
String destination = URIUtil.encodePath(deleteditemsUrl) + '/' + UUID.randomUUID().toString();
|
String destination = URIUtil.encodePath(deleteditemsUrl) + '/' + UUID.randomUUID().toString();
|
||||||
LOGGER.debug("Deleting : " + message.permanentUrl + " to " + destination);
|
LOGGER.debug("Deleting : " + message.permanentUrl + " to " + destination);
|
||||||
MoveMethod method = new MoveMethod(message.permanentUrl, destination, false);
|
MoveMethod method = new MoveMethod(encodeAndFixUrl(message.permanentUrl), destination, false);
|
||||||
method.addRequestHeader("Allow-rename", "t");
|
method.addRequestHeader("Allow-rename", "t");
|
||||||
|
|
||||||
int status = DavGatewayHttpClientFacade.executeHttpMethod(httpClient, method);
|
int status = DavGatewayHttpClientFacade.executeHttpMethod(httpClient, method);
|
||||||
|
Loading…
Reference in New Issue
Block a user