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
|
||||
# ``normpath`` should clean malformed and malicious request paths
|
||||
attributes = posixpath.normpath(self.path.strip("/")).split("/")
|
||||
if len(attributes) >= 2:
|
||||
path = "%s/%s" % (attributes[0], attributes[1])
|
||||
elif len(attributes) == 1: # no owner
|
||||
path = attributes[0]
|
||||
else:
|
||||
return
|
||||
|
||||
if attributes:
|
||||
path = "/".join(attributes[:min(len(attributes), 2)])
|
||||
return ical.Calendar(path)
|
||||
|
||||
def _decode(self, text):
|
||||
|
@ -56,7 +56,8 @@ def _sha1(hash_value, password):
|
||||
|
||||
def has_right(owner, user, password):
|
||||
"""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
|
||||
|
||||
for line in open(FILENAME).readlines():
|
||||
|
@ -135,16 +135,9 @@ class Calendar(object):
|
||||
|
||||
def __init__(self, path):
|
||||
"""Initialize the calendar with ``cal`` and ``user`` parameters."""
|
||||
|
||||
split_path = path.split("/")
|
||||
|
||||
self.encoding = "utf-8"
|
||||
|
||||
if len(split_path) > 1:
|
||||
self.owner = split_path[0]
|
||||
else:
|
||||
self.owner = None
|
||||
|
||||
split_path = path.split("/")
|
||||
self.owner = split_path[0] if len(split_path) > 1 else None
|
||||
self.path = os.path.join(FOLDER, path.replace("/", os.path.sep))
|
||||
|
||||
@staticmethod
|
||||
|
Loading…
Reference in New Issue
Block a user