Browse Source

[api] Fix handling of restricted file types in /rename API when the config is not set

Harsh Gupta 9 months ago
parent
commit
d492822ba0
1 changed files with 1 additions and 1 deletions
  1. 1 1
      apps/filebrowser/src/filebrowser/api.py

+ 1 - 1
apps/filebrowser/src/filebrowser/api.py

@@ -620,7 +620,7 @@ def rename(request):
   _, source_path_ext = os.path.splitext(source_path)
   _, source_path_ext = os.path.splitext(source_path)
   _, dest_path_ext = os.path.splitext(destination_path)
   _, dest_path_ext = os.path.splitext(destination_path)
 
 
-  restricted_file_types = [ext.lower() for ext in RESTRICT_FILE_EXTENSIONS.get()]
+  restricted_file_types = [ext.lower() for ext in RESTRICT_FILE_EXTENSIONS.get()] if RESTRICT_FILE_EXTENSIONS.get() else []
   # Check if destination path has a restricted file type and it doesn't match the source file type
   # Check if destination path has a restricted file type and it doesn't match the source file type
   if dest_path_ext.lower() in restricted_file_types and (source_path_ext.lower() != dest_path_ext.lower()):
   if dest_path_ext.lower() in restricted_file_types and (source_path_ext.lower() != dest_path_ext.lower()):
     return HttpResponse(f'Cannot rename file to a restricted file type: "{dest_path_ext}"', status=403)
     return HttpResponse(f'Cannot rename file to a restricted file type: "{dest_path_ext}"', status=403)