2222from ..filesystem import get_filesystem_encoding
2323from ..http import http_date
2424from ..http import is_resource_modified
25+ from ..security import safe_join
2526from ..wsgi import get_path_info
2627from ..wsgi import wrap_file
2728
@@ -149,7 +150,7 @@ def loader(path):
149150 if path is None :
150151 return None , None
151152
152- path = posixpath . join (package_path , path )
153+ path = safe_join (package_path , path )
153154
154155 if not provider .has_resource (path ):
155156 return None , None
@@ -170,7 +171,7 @@ def loader(path):
170171 def get_directory_loader (self , directory ):
171172 def loader (path ):
172173 if path is not None :
173- path = os . path . join (directory , path )
174+ path = safe_join (directory , path )
174175 else :
175176 path = directory
176177
@@ -192,19 +193,11 @@ def generate_etag(self, mtime, file_size, real_filename):
192193 )
193194
194195 def __call__ (self , environ , start_response ):
195- cleaned_path = get_path_info (environ )
196+ path = get_path_info (environ )
196197
197198 if PY2 :
198- cleaned_path = cleaned_path .encode (get_filesystem_encoding ())
199+ path = path .encode (get_filesystem_encoding ())
199200
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 != ".." )
208201 file_loader = None
209202
210203 for search_path , loader in self .exports :
0 commit comments