diff options
author | django-bot <ops@djangoproject.com> | 2022-02-03 20:24:19 +0100 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-02-07 20:37:05 +0100 |
commit | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 (patch) | |
tree | f0506b668a013d0063e5fba3dbf4863b466713ba /django/core/files/utils.py | |
parent | f68fa8b45dfac545cfc4111d4e52804c86db68d3 (diff) | |
download | django-9c19aff7c7561e3a82978a272ecdaad40dda5c00.tar.gz |
Refs #33476 -- Reformatted code with Black.
Diffstat (limited to 'django/core/files/utils.py')
-rw-r--r-- | django/core/files/utils.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/django/core/files/utils.py b/django/core/files/utils.py index f28cea1077..85342b2f3f 100644 --- a/django/core/files/utils.py +++ b/django/core/files/utils.py @@ -6,7 +6,7 @@ from django.core.exceptions import SuspiciousFileOperation def validate_file_name(name, allow_relative_path=False): # Remove potentially dangerous names - if os.path.basename(name) in {'', '.', '..'}: + if os.path.basename(name) in {"", ".", ".."}: raise SuspiciousFileOperation("Could not derive file name from '%s'" % name) if allow_relative_path: @@ -14,7 +14,7 @@ def validate_file_name(name, allow_relative_path=False): # FileField.generate_filename() where all file paths are expected to be # Unix style (with forward slashes). path = pathlib.PurePosixPath(name) - if path.is_absolute() or '..' in path.parts: + if path.is_absolute() or ".." in path.parts: raise SuspiciousFileOperation( "Detected path traversal attempt in '%s'" % name ) @@ -56,21 +56,21 @@ class FileProxyMixin: def readable(self): if self.closed: return False - if hasattr(self.file, 'readable'): + if hasattr(self.file, "readable"): return self.file.readable() return True def writable(self): if self.closed: return False - if hasattr(self.file, 'writable'): + if hasattr(self.file, "writable"): return self.file.writable() - return 'w' in getattr(self.file, 'mode', '') + return "w" in getattr(self.file, "mode", "") def seekable(self): if self.closed: return False - if hasattr(self.file, 'seekable'): + if hasattr(self.file, "seekable"): return self.file.seekable() return True |