File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -21,13 +21,13 @@ def browse_directory(
2121):
2222 full_path = os .path .abspath (os .path .join (BASE_DIR , path ))
2323
24- if not os .path .exists (full_path ) or not os .path .isdir (full_path ):
25- raise HTTPException (status_code = 404 , detail = "Directory not found" )
26-
2724 # Ensure path is within the base directory
28- if not os . path . commonpath ([ BASE_DIR , full_path ]) == BASE_DIR :
25+ if not full_path . startswith ( BASE_DIR ) :
2926 raise HTTPException (status_code = 403 , detail = "Access denied" )
3027
28+ if not os .path .exists (full_path ) or not os .path .isdir (full_path ):
29+ raise HTTPException (status_code = 404 , detail = "Directory not found" )
30+
3131 # List directories inside the path and sort them
3232 sorted_folders = []
3333 sorted_files = []
You can’t perform that action at this time.
0 commit comments