From 69c94c8d93c738d8307e998122bc8509a4e5db54 Mon Sep 17 00:00:00 2001 From: rfc2822 Date: Fri, 31 Oct 2014 17:32:16 +0100 Subject: [PATCH] Ensure trailing slash on user-given base URL (assuming users will always provide collections or base paths) --- src/at/bitfire/davdroid/resource/DavResourceFinder.java | 7 +++++-- src/at/bitfire/davdroid/webdav/TlsSniSocketFactory.java | 4 ++-- src/at/bitfire/davdroid/webdav/WebDavResource.java | 5 ++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/at/bitfire/davdroid/resource/DavResourceFinder.java b/src/at/bitfire/davdroid/resource/DavResourceFinder.java index 389d0724..449af5af 100644 --- a/src/at/bitfire/davdroid/resource/DavResourceFinder.java +++ b/src/at/bitfire/davdroid/resource/DavResourceFinder.java @@ -12,6 +12,7 @@ import ezvcard.VCardVersion; import android.content.Context; import android.util.Log; import at.bitfire.davdroid.R; +import at.bitfire.davdroid.URIUtils; import at.bitfire.davdroid.webdav.DavException; import at.bitfire.davdroid.webdav.DavHttpClient; import at.bitfire.davdroid.webdav.DavIncapableException; @@ -27,8 +28,9 @@ public class DavResourceFinder { // disable compression and enable network logging for debugging purposes CloseableHttpClient httpClient = DavHttpClient.create(true, true); - WebDavResource base = new WebDavResource(httpClient, new URI(serverInfo.getProvidedURL()), serverInfo.getUserName(), - serverInfo.getPassword(), serverInfo.isAuthPreemptive()); + WebDavResource base = new WebDavResource(httpClient, + new URI(URIUtils.ensureTrailingSlash(serverInfo.getProvidedURL())), + serverInfo.getUserName(), serverInfo.getPassword(), serverInfo.isAuthPreemptive()); // CardDAV WebDavResource principal = getCurrentUserPrincipal(base, "carddav"); @@ -159,6 +161,7 @@ public class DavResourceFinder { } catch (DavException e) { Log.d(TAG, "DAV error when querying principal for " + serviceName + " service", e); } + Log.i(TAG, "Couldn't find current-user-principal for service " + serviceName); return null; } diff --git a/src/at/bitfire/davdroid/webdav/TlsSniSocketFactory.java b/src/at/bitfire/davdroid/webdav/TlsSniSocketFactory.java index fae6c9f8..7a116814 100644 --- a/src/at/bitfire/davdroid/webdav/TlsSniSocketFactory.java +++ b/src/at/bitfire/davdroid/webdav/TlsSniSocketFactory.java @@ -135,7 +135,7 @@ public class TlsSniSocketFactory implements LayeredConnectionSocketFactory { for (String protocol : ssl.getSupportedProtocols()) if (!protocol.toUpperCase().contains("SSL")) protocols.add(protocol); - Log.d(TAG, "Setting allowed TLS protocols: " + StringUtils.join(protocols, ", ")); + Log.v(TAG, "Setting allowed TLS protocols: " + StringUtils.join(protocols, ", ")); ssl.setEnabledProtocols(protocols.toArray(new String[0])); // choose secure cipher suites @@ -173,7 +173,7 @@ public class TlsSniSocketFactory implements LayeredConnectionSocketFactory { HashSet enabledCiphers = new HashSet(Arrays.asList(ssl.getEnabledCipherSuites())); enabledCiphers.addAll(preferredCiphers); - Log.d(TAG, "Setting allowed TLS ciphers: " + StringUtils.join(enabledCiphers, ", ")); + Log.v(TAG, "Setting allowed TLS ciphers: " + StringUtils.join(enabledCiphers, ", ")); ssl.setEnabledCipherSuites(enabledCiphers.toArray(new String[0])); } diff --git a/src/at/bitfire/davdroid/webdav/WebDavResource.java b/src/at/bitfire/davdroid/webdav/WebDavResource.java index dbc13ece..f213f1d3 100644 --- a/src/at/bitfire/davdroid/webdav/WebDavResource.java +++ b/src/at/bitfire/davdroid/webdav/WebDavResource.java @@ -558,14 +558,13 @@ public class WebDavResource { } // about which resource is this response? - // "this" resource is either at "location" … - if (location.equals(href)) { // -> ourselves + if (location.equals(href)) { // about ourselves this.properties.putAll(properties); if (supportedComponents != null) this.supportedComponents = supportedComponents; this.content = data; - } else { + } else { // about a member WebDavResource member = new WebDavResource(this, href); member.properties = properties; member.supportedComponents = supportedComponents;