Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Do not allow FileSystemStorage.delete to receive an empty name

Refs #20660.
  • Loading branch information...
commit 7fbab3ebaf8b60bbe847b772f895df47067a60d3 1 parent ea3fe78
@claudep claudep authored
Showing with 9 additions and 0 deletions.
  1. +1 −0  django/core/files/storage.py
  2. +8 −0 tests/file_storage/tests.py
View
1  django/core/files/storage.py
@@ -231,6 +231,7 @@ def _save(self, name, content):
return name
def delete(self, name):
+ assert name, "The name argument is not allowed to be empty."
name = self.path(name)
# If the file exists, delete it from the filesystem.
# Note that there is a race between os.path.exists and os.remove:
View
8 tests/file_storage/tests.py
@@ -364,6 +364,14 @@ def failing_chunks():
with self.assertRaises(IOError):
self.storage.save('error.file', f1)
+ def test_delete_no_name(self):
+ """
+ Calling delete with an empty name should not try to remove the base
+ storage directory, but fail loudly (#20660).
+ """
+ with self.assertRaises(AssertionError):
+ self.storage.delete('')
+
class CustomStorage(FileSystemStorage):
def get_available_name(self, name):

0 comments on commit 7fbab3e

Please sign in to comment.
Something went wrong with that request. Please try again.