diff --git a/radicale/__init__.py b/radicale/__init__.py index 38e6e5f..7e8deb5 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -514,9 +514,8 @@ class Application(object): headers = { "DAV": "1, 2, 3, calendar-access, addressbook, extended-mkcol", "Content-Type": "text/xml"} - collections = set(read_collections + write_collections) answer = xmlutils.propfind( - environ["PATH_INFO"], content, collections, user) + environ["PATH_INFO"], content, read_collections, write_collections, user) return client.MULTI_STATUS, headers, answer def do_PROPPATCH(self, environ, read_collections, write_collections, diff --git a/radicale/xmlutils.py b/radicale/xmlutils.py index 8bfdd15..d7fe155 100644 --- a/radicale/xmlutils.py +++ b/radicale/xmlutils.py @@ -30,7 +30,7 @@ import xml.etree.ElementTree as ET from collections import OrderedDict from urllib.parse import unquote, urlparse -from . import client, config, ical, rights +from . import client, config, ical NAMESPACES = { @@ -187,7 +187,7 @@ def delete(path, collection): return _pretty_xml(multistatus) -def propfind(path, xml_request, collections, user=None): +def propfind(path, xml_request, read_collections, write_collections, user=None): """Read and answer PROPFIND requests. Read rfc4918-9.1 for info. @@ -213,14 +213,21 @@ def propfind(path, xml_request, collections, user=None): # Writing answer multistatus = ET.Element(_tag("D", "multistatus")) - for collection in collections: - response = _propfind_response(path, collection, props, user) + collections = [] + for collection in write_collections: + collections.append(collection) + response = _propfind_response(path, collection, props, user, write=True) + multistatus.append(response) + for collection in read_collections: + if collection in collections: + continue + response = _propfind_response(path, collection, props, user, write=False) multistatus.append(response) return _pretty_xml(multistatus) -def _propfind_response(path, item, props, user): +def _propfind_response(path, item, props, user, write=False): """Build and return a PROPFIND response.""" is_collection = isinstance(item, ical.Collection) if is_collection: @@ -280,13 +287,12 @@ def _propfind_response(path, item, props, user): element.append(tag) elif tag == _tag("D", "current-user-privilege-set"): privilege = ET.Element(_tag("D", "privilege")) - if rights.authorized(user, item, "w"): + if write: privilege.append(ET.Element(_tag("D", "all"))) - privilege.append(ET.Element(_tag("D", "read"))) - if rights.authorized(user, item, "w"): privilege.append(ET.Element(_tag("D", "write"))) privilege.append(ET.Element(_tag("D", "write-properties"))) privilege.append(ET.Element(_tag("D", "write-content"))) + privilege.append(ET.Element(_tag("D", "read"))) element.append(privilege) elif tag == _tag("D", "supported-report-set"): for report_name in (