From b5df8a45146af2e18fa1073c0d74e151b3c8f170 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Mon, 12 May 2014 18:54:04 +0200 Subject: [PATCH] Possible fix for #49 - Radicale incorrectly unquotes URLs - Older versions of radicale are so buggy they fail to look up items with url quotes in them. - ownCloud/SabreDAV follows the rebustness principle such that it takes anything, but returns properly encoded URLs. Conclusion: Send broken, unquoted URLs, because both sides seem to be happy with them. As wrong as it might seem, it works. --- vdirsyncer/storage/dav.py | 3 ++- vdirsyncer/utils.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/vdirsyncer/storage/dav.py b/vdirsyncer/storage/dav.py index 4715a21..bf2e5ed 100644 --- a/vdirsyncer/storage/dav.py +++ b/vdirsyncer/storage/dav.py @@ -117,9 +117,10 @@ class DavStorage(Storage): schema.''' x = utils.urlparse.urljoin(self.url, href) assert x.startswith(self.url) - return utils.urlparse.urlsplit(x).path + return utils.urlunquote_plus(utils.urlparse.urlsplit(x).path) def _get_href(self, uid): + uid = utils.urlunquote_plus(uid) return self._normalize_href(super(DavStorage, self)._get_href(uid)) def _request(self, method, path, data=None, headers=None): diff --git a/vdirsyncer/utils.py b/vdirsyncer/utils.py index 505ea0b..ffea748 100644 --- a/vdirsyncer/utils.py +++ b/vdirsyncer/utils.py @@ -22,11 +22,16 @@ PY2 = sys.version_info[0] == 2 if PY2: import urlparse + from urllib import \ + quote_plus as urlquote_plus, \ + unquote_plus as urlunquote_plus text_type = unicode # flake8: noqa iteritems = lambda x: x.iteritems() itervalues = lambda x: x.itervalues() else: import urllib.parse as urlparse + urlquote_plus = urlparse.quote_plus + urlunquote_plus = urlparse.unquote_plus text_type = str iteritems = lambda x: x.items() itervalues = lambda x: x.values()