diff options
Diffstat (limited to 'django/template/backends')
| -rw-r--r-- | django/template/backends/base.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/django/template/backends/base.py b/django/template/backends/base.py index 4156365b97..c47c95e51e 100644 --- a/django/template/backends/base.py +++ b/django/template/backends/base.py @@ -1,5 +1,3 @@ -from contextlib import suppress - from django.core.exceptions import ( ImproperlyConfigured, SuspiciousFileOperation, ) @@ -75,8 +73,9 @@ class BaseEngine: directory traversal attacks. """ for template_dir in self.template_dirs: - # SuspiciousFileOperation occurs if the jointed path is located - # outside of this template_dir (it might be inside another one, - # so this isn't fatal). - with suppress(SuspiciousFileOperation): + try: yield safe_join(template_dir, template_name) + except SuspiciousFileOperation: + # The joined path was located outside of this template_dir + # (it might be inside another one, so this isn't fatal). + pass |
