Use posixpath instead of os.path to normalize request path.
This commit is contained in:
parent
690a76c3b7
commit
f38576d999
@ -34,6 +34,7 @@ should have been included in this package.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import posixpath
|
||||||
import base64
|
import base64
|
||||||
import socket
|
import socket
|
||||||
# Manage Python2/3 different modules
|
# Manage Python2/3 different modules
|
||||||
@ -106,8 +107,9 @@ class CalendarHTTPHandler(server.BaseHTTPRequestHandler):
|
|||||||
@property
|
@property
|
||||||
def _calendar(self):
|
def _calendar(self):
|
||||||
"""The ``ical.Calendar`` object corresponding to the given path."""
|
"""The ``ical.Calendar`` object corresponding to the given 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 = os.path.normpath(self.path.strip("/")).split("/")
|
attributes = posixpath.normpath(self.path.strip("/")).split("/")
|
||||||
if len(attributes) >= 2:
|
if len(attributes) >= 2:
|
||||||
path = "%s/%s" % (attributes[0], attributes[1])
|
path = "%s/%s" % (attributes[0], attributes[1])
|
||||||
return ical.Calendar(path)
|
return ical.Calendar(path)
|
||||||
|
Loading…
Reference in New Issue
Block a user