From 140af81eada55104896eb2289ded58001f03fa65 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Mon, 25 Jul 2016 02:25:43 +0200 Subject: [PATCH] Fix XML querying bug Fix #480 --- tests/storage/dav/test_main.py | 27 +++++++++++++++++++++++++++ vdirsyncer/storage/dav.py | 4 +++- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/storage/dav/test_main.py diff --git a/tests/storage/dav/test_main.py b/tests/storage/dav/test_main.py new file mode 100644 index 0000000..6a8be54 --- /dev/null +++ b/tests/storage/dav/test_main.py @@ -0,0 +1,27 @@ +from vdirsyncer.storage.dav import _parse_xml, _merge_xml + +def test_xml_utilities(): + x = _parse_xml(''' + + + + HTTP/1.1 404 Not Found + + + + + + + + + + + + + + ''') + + response = x.find('{DAV:}response') + props = _merge_xml(response.findall('{DAV:}propstat/{DAV:}prop')) + assert props.find('{DAV:}resourcetype/{DAV:}collection') is not None + assert props.find('{DAV:}getcontenttype') is not None diff --git a/vdirsyncer/storage/dav.py b/vdirsyncer/storage/dav.py index 0025678..2809b93 100644 --- a/vdirsyncer/storage/dav.py +++ b/vdirsyncer/storage/dav.py @@ -79,7 +79,8 @@ def _parse_xml(content): def _merge_xml(items): rv = items[0] - rv.extend(items[1:]) + for item in items[1:]: + rv.extend(item.getiterator()) return rv @@ -544,6 +545,7 @@ class DavStorage(Storage): if not etag: dav_logger.warning('Skipping {!r}, etag property is missing.' .format(href)) + continue contenttype = getattr(props.find('{DAV:}getcontenttype'), 'text', None)