Check if REPORT method is supported on collection

This commit is contained in:
Unrud 2017-12-06 21:46:23 +01:00
parent bf272a99db
commit 2b1d3ce3d2

View File

@ -1140,6 +1140,16 @@ def report(base_prefix, path, xml_request, collection):
logger.warning("Unsupported REPORT method %r on %r requested", logger.warning("Unsupported REPORT method %r on %r requested",
_tag_from_clark(root.tag), path) _tag_from_clark(root.tag), path)
return client.MULTI_STATUS, multistatus return client.MULTI_STATUS, multistatus
if (root.tag == _tag("C", "calendar-multiget") and
collection.get_meta("tag") != "VCALENDAR" or
root.tag == _tag("CR", "addressbook-multiget") and
collection.get_meta("tag") != "VADDRESSBOOK" or
root.tag == _tag("D", "sync-collection") and
collection.get_meta("tag") not in ("VADDRESSBOOK", "VCALENDAR")):
logger.warning("Invalid REPORT method %r on %r requested",
_tag_from_clark(root.tag), path)
return (client.PRECONDITION_FAILED,
_webdav_error("D", "supported-report"))
prop_element = root.find(_tag("D", "prop")) prop_element = root.find(_tag("D", "prop"))
props = ( props = (
[prop.tag for prop in prop_element] [prop.tag for prop in prop_element]