From 9c19aff7c7561e3a82978a272ecdaad40dda5c00 Mon Sep 17 00:00:00 2001 From: django-bot Date: Thu, 3 Feb 2022 20:24:19 +0100 Subject: Refs #33476 -- Reformatted code with Black. --- django/core/files/utils.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'django/core/files/utils.py') 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 -- cgit v1.2.1