22
22
from ..filesystem import get_filesystem_encoding
23
23
from ..http import http_date
24
24
from ..http import is_resource_modified
25
+ from ..security import safe_join
25
26
from ..wsgi import get_path_info
26
27
from ..wsgi import wrap_file
27
28
@@ -149,7 +150,7 @@ def loader(path):
149
150
if path is None :
150
151
return None , None
151
152
152
- path = posixpath . join (package_path , path )
153
+ path = safe_join (package_path , path )
153
154
154
155
if not provider .has_resource (path ):
155
156
return None , None
@@ -170,7 +171,7 @@ def loader(path):
170
171
def get_directory_loader (self , directory ):
171
172
def loader (path ):
172
173
if path is not None :
173
- path = os . path . join (directory , path )
174
+ path = safe_join (directory , path )
174
175
else :
175
176
path = directory
176
177
@@ -192,19 +193,11 @@ def generate_etag(self, mtime, file_size, real_filename):
192
193
)
193
194
194
195
def __call__ (self , environ , start_response ):
195
- cleaned_path = get_path_info (environ )
196
+ path = get_path_info (environ )
196
197
197
198
if PY2 :
198
- cleaned_path = cleaned_path .encode (get_filesystem_encoding ())
199
+ path = path .encode (get_filesystem_encoding ())
199
200
200
- # sanitize the path for non unix systems
201
- cleaned_path = cleaned_path .strip ("/" )
202
-
203
- for sep in os .sep , os .altsep :
204
- if sep and sep != "/" :
205
- cleaned_path = cleaned_path .replace (sep , "/" )
206
-
207
- path = "/" + "/" .join (x for x in cleaned_path .split ("/" ) if x and x != ".." )
208
201
file_loader = None
209
202
210
203
for search_path , loader in self .exports :
0 commit comments