mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Fix multiple issues with URL handling in discovery
This commit is contained in:
parent
6147da0676
commit
f043bdfb12
2 changed files with 6 additions and 5 deletions
|
|
@ -20,6 +20,7 @@ Version 0.4.3
|
||||||
Baikal or ownCloud.
|
Baikal or ownCloud.
|
||||||
- Removed some workarounds for Radicale. Upgrading to the latest Radicale will
|
- Removed some workarounds for Radicale. Upgrading to the latest Radicale will
|
||||||
fix the issues.
|
fix the issues.
|
||||||
|
- Fixed issues with iCloud discovery.
|
||||||
|
|
||||||
Version 0.4.2
|
Version 0.4.2
|
||||||
=============
|
=============
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ class Discover(object):
|
||||||
rv = root.find('.//{DAV:}current-user-principal/{DAV:}href')
|
rv = root.find('.//{DAV:}current-user-principal/{DAV:}href')
|
||||||
if rv is None:
|
if rv is None:
|
||||||
raise InvalidXMLResponse()
|
raise InvalidXMLResponse()
|
||||||
return rv.text
|
return utils.urlparse.urljoin(response.url, rv.text)
|
||||||
|
|
||||||
def find_home(self, url=None):
|
def find_home(self, url=None):
|
||||||
if url is None:
|
if url is None:
|
||||||
|
|
@ -136,16 +136,16 @@ class Discover(object):
|
||||||
rv = root.find('.//' + self._homeset_tag + '/{*}href')
|
rv = root.find('.//' + self._homeset_tag + '/{*}href')
|
||||||
if rv is None:
|
if rv is None:
|
||||||
raise InvalidXMLResponse()
|
raise InvalidXMLResponse()
|
||||||
return rv.text
|
return utils.urlparse.urljoin(response.url, rv.text)
|
||||||
|
|
||||||
def find_collections(self, url=None):
|
def find_collections(self, url=None):
|
||||||
if url is None:
|
if url is None:
|
||||||
url = self.find_home()
|
url = self.find_home()
|
||||||
headers = self.session.get_default_headers()
|
headers = self.session.get_default_headers()
|
||||||
headers['Depth'] = 1
|
headers['Depth'] = 1
|
||||||
response = self.session.request('PROPFIND', url, headers=headers,
|
r = self.session.request('PROPFIND', url, headers=headers,
|
||||||
data=self._collection_xml)
|
data=self._collection_xml)
|
||||||
root = _parse_xml(response.content)
|
root = _parse_xml(r.content)
|
||||||
done = set()
|
done = set()
|
||||||
for response in root.findall('{DAV:}response'):
|
for response in root.findall('{DAV:}response'):
|
||||||
props = _merge_xml(response.findall('{*}propstat/{*}prop'))
|
props = _merge_xml(response.findall('{*}propstat/{*}prop'))
|
||||||
|
|
@ -156,7 +156,7 @@ class Discover(object):
|
||||||
href = response.find('{*}href')
|
href = response.find('{*}href')
|
||||||
if href is None:
|
if href is None:
|
||||||
raise InvalidXMLResponse()
|
raise InvalidXMLResponse()
|
||||||
href = utils.urlparse.urljoin(self.session.url, href.text)
|
href = utils.urlparse.urljoin(r.url, href.text)
|
||||||
if href not in done:
|
if href not in done:
|
||||||
done.add(href)
|
done.add(href)
|
||||||
yield {'href': href, 'displayname': displayname}
|
yield {'href': href, 'displayname': displayname}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue