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