Fix issues with base_prefix option
This commit is contained in:
parent
54bda5594c
commit
0dbf71f57f
2
config
2
config
@ -27,7 +27,7 @@ certificate = /etc/apache2/ssl/server.crt
|
|||||||
key = /etc/apache2/ssl/server.key
|
key = /etc/apache2/ssl/server.key
|
||||||
# Reverse DNS to resolve client address in logs
|
# Reverse DNS to resolve client address in logs
|
||||||
dns_lookup = True
|
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 =
|
base_prefix =
|
||||||
|
|
||||||
[encoding]
|
[encoding]
|
||||||
|
@ -226,8 +226,10 @@ def _propfind_response(path, item, props, user):
|
|||||||
response = ET.Element(_tag("D", "response"))
|
response = ET.Element(_tag("D", "response"))
|
||||||
|
|
||||||
href = ET.Element(_tag("D", "href"))
|
href = ET.Element(_tag("D", "href"))
|
||||||
uri = item.url if is_collection else "%s/%s" % (path, item.name)
|
if is_collection:
|
||||||
uri = "%s/%s" % (config.get("server", "base_prefix"), uri)
|
uri = "%s%s" % (config.get("server", "base_prefix"), item.url)
|
||||||
|
else:
|
||||||
|
uri = "%s/%s" % (path, item.name)
|
||||||
href.text = uri.replace("//", "/")
|
href.text = uri.replace("//", "/")
|
||||||
response.append(href)
|
response.append(href)
|
||||||
|
|
||||||
@ -267,7 +269,7 @@ def _propfind_response(path, item, props, user):
|
|||||||
# pylint: enable=W0511
|
# pylint: enable=W0511
|
||||||
elif tag == _tag("D", "current-user-principal") and user:
|
elif tag == _tag("D", "current-user-principal") and user:
|
||||||
tag = ET.Element(_tag("D", "href"))
|
tag = ET.Element(_tag("D", "href"))
|
||||||
tag.text = "/%s/" % user
|
tag.text = "%s/%s/" % (config.get("server", "base_prefix"), user)
|
||||||
element.append(tag)
|
element.append(tag)
|
||||||
elif tag == _tag("D", "current-user-privilege-set"):
|
elif tag == _tag("D", "current-user-privilege-set"):
|
||||||
privilege = ET.Element(_tag("D", "privilege"))
|
privilege = ET.Element(_tag("D", "privilege"))
|
||||||
@ -461,9 +463,12 @@ def report(path, xml_request, collection):
|
|||||||
collection_headers = collection.headers
|
collection_headers = collection.headers
|
||||||
collection_timezones = collection.timezones
|
collection_timezones = collection.timezones
|
||||||
|
|
||||||
|
base_prefix = config.get("server", "base_prefix")
|
||||||
|
|
||||||
for hreference in hreferences:
|
for hreference in hreferences:
|
||||||
|
unprefixed_hreference = hreference[len(base_prefix):]
|
||||||
# Check if the reference is an item or a collection
|
# 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:
|
if name:
|
||||||
# Reference is an item
|
# Reference is an item
|
||||||
path = "/".join(hreference.split("/")[:-1]) + "/"
|
path = "/".join(hreference.split("/")[:-1]) + "/"
|
||||||
|
Loading…
Reference in New Issue
Block a user