From f043bdfb12b6edb601a9d30f2bf412147ecbe2b0 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Mon, 16 Feb 2015 18:17:16 +0100 Subject: [PATCH] Fix multiple issues with URL handling in discovery --- CHANGELOG.rst | 1 + vdirsyncer/storage/dav.py | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6126600..c2ca153 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -20,6 +20,7 @@ Version 0.4.3 Baikal or ownCloud. - Removed some workarounds for Radicale. Upgrading to the latest Radicale will fix the issues. +- Fixed issues with iCloud discovery. Version 0.4.2 ============= diff --git a/vdirsyncer/storage/dav.py b/vdirsyncer/storage/dav.py index c43a08f..1dffaab 100644 --- a/vdirsyncer/storage/dav.py +++ b/vdirsyncer/storage/dav.py @@ -120,7 +120,7 @@ class Discover(object): rv = root.find('.//{DAV:}current-user-principal/{DAV:}href') if rv is None: raise InvalidXMLResponse() - return rv.text + return utils.urlparse.urljoin(response.url, rv.text) def find_home(self, url=None): if url is None: @@ -136,16 +136,16 @@ class Discover(object): rv = root.find('.//' + self._homeset_tag + '/{*}href') if rv is None: raise InvalidXMLResponse() - return rv.text + return utils.urlparse.urljoin(response.url, rv.text) def find_collections(self, url=None): if url is None: url = self.find_home() headers = self.session.get_default_headers() headers['Depth'] = 1 - response = self.session.request('PROPFIND', url, headers=headers, + r = self.session.request('PROPFIND', url, headers=headers, data=self._collection_xml) - root = _parse_xml(response.content) + root = _parse_xml(r.content) done = set() for response in root.findall('{DAV:}response'): props = _merge_xml(response.findall('{*}propstat/{*}prop')) @@ -156,7 +156,7 @@ class Discover(object): href = response.find('{*}href') if href is None: raise InvalidXMLResponse() - href = utils.urlparse.urljoin(self.session.url, href.text) + href = utils.urlparse.urljoin(r.url, href.text) if href not in done: done.add(href) yield {'href': href, 'displayname': displayname}