Clean owner-less calendars support (fixes #254)
This commit is contained in:
parent
6c65cc1539
commit
5673444ba7
@ -175,13 +175,8 @@ class CalendarHTTPHandler(server.BaseHTTPRequestHandler):
|
|||||||
# ``self.path`` must be something like a posix path
|
# ``self.path`` must be something like a posix path
|
||||||
# ``normpath`` should clean malformed and malicious request paths
|
# ``normpath`` should clean malformed and malicious request paths
|
||||||
attributes = posixpath.normpath(self.path.strip("/")).split("/")
|
attributes = posixpath.normpath(self.path.strip("/")).split("/")
|
||||||
if len(attributes) >= 2:
|
if attributes:
|
||||||
path = "%s/%s" % (attributes[0], attributes[1])
|
path = "/".join(attributes[:min(len(attributes), 2)])
|
||||||
elif len(attributes) == 1: # no owner
|
|
||||||
path = attributes[0]
|
|
||||||
else:
|
|
||||||
return
|
|
||||||
|
|
||||||
return ical.Calendar(path)
|
return ical.Calendar(path)
|
||||||
|
|
||||||
def _decode(self, text):
|
def _decode(self, text):
|
||||||
|
@ -56,7 +56,8 @@ def _sha1(hash_value, password):
|
|||||||
|
|
||||||
def has_right(owner, user, password):
|
def has_right(owner, user, password):
|
||||||
"""Check if ``user``/``password`` couple is valid."""
|
"""Check if ``user``/``password`` couple is valid."""
|
||||||
if owner is None: # no owner - everybody is allowed
|
if owner is None and PERSONAL:
|
||||||
|
# No owner and personal calendars, everybody is allowed
|
||||||
return True
|
return True
|
||||||
|
|
||||||
for line in open(FILENAME).readlines():
|
for line in open(FILENAME).readlines():
|
||||||
|
@ -135,16 +135,9 @@ class Calendar(object):
|
|||||||
|
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
"""Initialize the calendar with ``cal`` and ``user`` parameters."""
|
"""Initialize the calendar with ``cal`` and ``user`` parameters."""
|
||||||
|
|
||||||
split_path = path.split("/")
|
|
||||||
|
|
||||||
self.encoding = "utf-8"
|
self.encoding = "utf-8"
|
||||||
|
split_path = path.split("/")
|
||||||
if len(split_path) > 1:
|
self.owner = split_path[0] if len(split_path) > 1 else None
|
||||||
self.owner = split_path[0]
|
|
||||||
else:
|
|
||||||
self.owner = None
|
|
||||||
|
|
||||||
self.path = os.path.join(FOLDER, path.replace("/", os.path.sep))
|
self.path = os.path.join(FOLDER, path.replace("/", os.path.sep))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Loading…
Reference in New Issue
Block a user