File tree Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Original file line number Diff line number Diff line change @@ -25,14 +25,10 @@ def get_prof_picture(self, path=None):
2525 if not path :
2626 pass
2727
28- # defends against path traversal attacks
29- if path .startswith ('/' ) or path .startswith ('..' ):
30- return None
31-
3228 # builds path
3329 base_dir = os .path .dirname (os .path .abspath (__file__ ))
3430 prof_picture_path = os .path .normpath (os .path .join (base_dir , path ))
35- if base_dir != os . path . commonpath ([ base_dir , prof_picture_path ] ):
31+ if not prof_picture_path . startswith ( base_dir ):
3632 return None
3733
3834 with open (prof_picture_path , 'rb' ) as pic :
@@ -52,7 +48,7 @@ def get_tax_form_attachment(self, path=None):
5248 # Validate the path to prevent path traversal attacks
5349 base_dir = os .path .dirname (os .path .abspath (__file__ ))
5450 tax_form_path = os .path .normpath (os .path .join (base_dir , path ))
55- if base_dir != os . path . commonpath ([ base_dir , tax_form_path ] ):
51+ if not tax_form_path . startswith ( base_dir ):
5652 return None
5753
5854 with open (tax_form_path , 'rb' ) as form :
You can’t perform that action at this time.
0 commit comments