mirror of
https://github.com/Kozea/Radicale.git
synced 2025-08-28 19:40:54 +00:00
Prevent unsafe usernames
If an attacker is able to create an account with a username like "user/calendar.ics", he can access collections of other users.
This commit is contained in:
parent
f4ebe3f545
commit
da1a693620
3 changed files with 20 additions and 1 deletions
|
@ -103,6 +103,15 @@ def get_etag(text):
|
|||
return '"%s"' % etag.hexdigest()
|
||||
|
||||
|
||||
def is_safe_path_component(path):
|
||||
"""Check if path is a single component of a path.
|
||||
|
||||
Check that the path is safe to join too.
|
||||
|
||||
"""
|
||||
return path and "/" not in path and path not in (".", "..")
|
||||
|
||||
|
||||
def sanitize_path(path):
|
||||
"""Make path absolute with leading slash to prevent access to other data.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue