Fix XML error messages

Fixes #825
This commit is contained in:
Unrud 2020-05-22 16:33:04 +02:00
parent 8740357eb2
commit 3be9a22a91
2 changed files with 6 additions and 3 deletions

View File

@ -1059,10 +1059,13 @@ class BaseRequestsMixIn:
</prop> </prop>
%s %s
</sync-collection>""" % sync_token_xml) </sync-collection>""" % sync_token_xml)
if sync_token and status == 409: xml = DefusedET.fromstring(answer)
if status in (403, 409):
assert xml.tag == xmlutils.make_clark("D:error")
assert sync_token and xml.find(
xmlutils.make_clark("D:valid-sync-token")) is not None
return None, None return None, None
assert status == 207 assert status == 207
xml = DefusedET.fromstring(answer)
assert xml.tag == xmlutils.make_clark("D:multistatus") assert xml.tag == xmlutils.make_clark("D:multistatus")
sync_token = xml.find(xmlutils.make_clark("D:sync-token")).text.strip() sync_token = xml.find(xmlutils.make_clark("D:sync-token")).text.strip()
assert sync_token assert sync_token

View File

@ -131,7 +131,7 @@ def make_href(base_prefix, href):
def webdav_error(human_tag): def webdav_error(human_tag):
"""Generate XML error message.""" """Generate XML error message."""
root = ET.Element(make_clark("D:error")) root = ET.Element(make_clark("D:error"))
root.append(ET.Element(human_tag)) root.append(ET.Element(make_clark(human_tag)))
return root return root