diff --git a/config b/config index 6ddf1ce..531f280 100644 --- a/config +++ b/config @@ -27,7 +27,7 @@ certificate = /etc/apache2/ssl/server.crt key = /etc/apache2/ssl/server.key # Reverse DNS to resolve client address in logs dns_lookup = True -# base URL if / is not the CalDAV root +# base URL if / is not the CalDAV root. If set, must start with / base_prefix = [encoding] diff --git a/radicale/xmlutils.py b/radicale/xmlutils.py index 29f131e..bd389b9 100644 --- a/radicale/xmlutils.py +++ b/radicale/xmlutils.py @@ -226,8 +226,10 @@ def _propfind_response(path, item, props, user): response = ET.Element(_tag("D", "response")) href = ET.Element(_tag("D", "href")) - uri = item.url if is_collection else "%s/%s" % (path, item.name) - uri = "%s/%s" % (config.get("server", "base_prefix"), uri) + if is_collection: + uri = "%s%s" % (config.get("server", "base_prefix"), item.url) + else: + uri = "%s/%s" % (path, item.name) href.text = uri.replace("//", "/") response.append(href) @@ -267,7 +269,7 @@ def _propfind_response(path, item, props, user): # pylint: enable=W0511 elif tag == _tag("D", "current-user-principal") and user: tag = ET.Element(_tag("D", "href")) - tag.text = "/%s/" % user + tag.text = "%s/%s/" % (config.get("server", "base_prefix"), user) element.append(tag) elif tag == _tag("D", "current-user-privilege-set"): privilege = ET.Element(_tag("D", "privilege")) @@ -461,9 +463,12 @@ def report(path, xml_request, collection): collection_headers = collection.headers collection_timezones = collection.timezones + base_prefix = config.get("server", "base_prefix") + for hreference in hreferences: + unprefixed_hreference = hreference[len(base_prefix):] # Check if the reference is an item or a collection - name = name_from_path(hreference, collection) + name = name_from_path(unprefixed_hreference, collection) if name: # Reference is an item path = "/".join(hreference.split("/")[:-1]) + "/"