Fix the iCal support (now tested with iCal, Lightning, Evolution)
This commit is contained in:
parent
d17e8fa990
commit
e9ad9b1716
@ -144,7 +144,11 @@ class Application(object):
|
||||
@staticmethod
|
||||
def sanitize_uri(uri):
|
||||
"""Clean URI: unquote and remove /../ to prevent access to other data."""
|
||||
return posixpath.normpath(unquote(uri))
|
||||
uri = unquote(uri)
|
||||
trailing_slash = "/" if uri.endswith("/") else ""
|
||||
uri = posixpath.normpath(uri)
|
||||
trailing_slash = "" if uri == "/" else trailing_slash
|
||||
return uri + trailing_slash
|
||||
|
||||
def __call__(self, environ, start_response):
|
||||
"""Manage a request."""
|
||||
|
@ -192,12 +192,12 @@ class Calendar(object):
|
||||
attributes = posixpath.normpath(path).strip("/").split("/")
|
||||
if not attributes:
|
||||
return None
|
||||
if attributes[-1].endswith(".ics"):
|
||||
if not (os.path.isfile(os.path.join(FOLDER, *attributes)) or path.endswith("/")):
|
||||
attributes.pop()
|
||||
|
||||
result = []
|
||||
|
||||
path = "/".join(attributes[:min(len(attributes), 2)])
|
||||
path = "/".join(attributes)
|
||||
abs_path = os.path.join(FOLDER, path.replace("/", os.sep))
|
||||
if os.path.isdir(abs_path):
|
||||
if depth == "0":
|
||||
@ -213,10 +213,10 @@ class Calendar(object):
|
||||
# Directory does not exist yet
|
||||
pass
|
||||
else:
|
||||
calendar = cls(path)
|
||||
if depth == "0":
|
||||
result.append(calendar)
|
||||
result.append(cls(path))
|
||||
else:
|
||||
calendar = cls(path, principal=True)
|
||||
if include_container:
|
||||
result.append(calendar)
|
||||
result.extend(calendar.components)
|
||||
|
@ -201,7 +201,7 @@ def _propfind_response(path, item, props, user):
|
||||
response = ET.Element(_tag("D", "response"))
|
||||
|
||||
href = ET.Element(_tag("D", "href"))
|
||||
href.text = item.url if is_calendar else "%s/%s" % (path, item.name)
|
||||
href.text = (item.url if is_calendar else "%s/%s" % (path, item.name)).replace('//', '/')
|
||||
response.append(href)
|
||||
|
||||
propstat404 = ET.Element(_tag("D", "propstat"))
|
||||
@ -221,12 +221,7 @@ def _propfind_response(path, item, props, user):
|
||||
element.text = item.etag
|
||||
elif tag == _tag("D", "principal-URL"):
|
||||
tag = ET.Element(_tag("D", "href"))
|
||||
if item.owner_url:
|
||||
tag.text = item.owner_url
|
||||
elif user:
|
||||
tag.text = '/%s/' % user
|
||||
else:
|
||||
tag.text = path
|
||||
tag.text = path
|
||||
element.append(tag)
|
||||
elif tag in (
|
||||
_tag("D", "principal-collection-set"),
|
||||
@ -267,8 +262,9 @@ def _propfind_response(path, item, props, user):
|
||||
if item.is_principal:
|
||||
tag = ET.Element(_tag("D", "principal"))
|
||||
element.append(tag)
|
||||
tag = ET.Element(_tag("C", "calendar"))
|
||||
element.append(tag)
|
||||
else:
|
||||
tag = ET.Element(_tag("C", "calendar"))
|
||||
element.append(tag)
|
||||
tag = ET.Element(_tag("D", "collection"))
|
||||
element.append(tag)
|
||||
elif tag == _tag("D", "owner") and item.owner_url:
|
||||
|
Loading…
Reference in New Issue
Block a user