=== modified file 'django/template/loaders/app_directories.py'
|
|
|
|
| 1 | | # Wrapper for loading templates from "template" directories in installed app packages. |
| | 1 | """ |
| | 2 | Wrapper for loading templates from "template" directories in INSTALLED_APPS |
| | 3 | packages. |
| | 4 | """ |
| | 5 | |
| | 6 | import os |
| 2 | 7 | |
| 3 | 8 | from django.conf import settings |
| 4 | 9 | from django.core.exceptions import ImproperlyConfigured |
| 5 | 10 | from django.template import TemplateDoesNotExist |
| 6 | | import os |
| 7 | 11 | |
| 8 | 12 | # At compile time, cache the directories to search. |
| 9 | 13 | app_template_dirs = [] |
| … |
… |
|
| 28 | 32 | app_template_dirs = tuple(app_template_dirs) |
| 29 | 33 | |
| 30 | 34 | def get_template_sources(template_name, template_dirs=None): |
| | 35 | is_absolute = os.path.isabs(template_name) |
| 31 | 36 | for template_dir in app_template_dirs: |
| | 37 | # When os.path.join encounters a component that is an absolute path, |
| | 38 | # all previous components are thrown away. That is not what we want |
| | 39 | # since os.path.join(['/template/dir/', '/etc/passwd'] -> '/etc/passwd' |
| | 40 | # So if the template_name given is an absolute path, only return it if |
| | 41 | # it is under the template_dir directory. |
| | 42 | if is_absolute and not template_name.startswith(template_dir): |
| | 43 | continue |
| 32 | 44 | yield os.path.join(template_dir, template_name) |
| 33 | 45 | |
| 34 | 46 | def load_template_source(template_name, template_dirs=None): |
=== modified file 'django/template/loaders/filesystem.py'
|
|
|
|
| 1 | | # Wrapper for loading templates from the filesystem. |
| | 1 | """ |
| | 2 | Wrapper for loading templates from the filesystem. |
| | 3 | """ |
| | 4 | |
| | 5 | import os |
| 2 | 6 | |
| 3 | 7 | from django.conf import settings |
| 4 | 8 | from django.template import TemplateDoesNotExist |
| 5 | | import os |
| 6 | 9 | |
| 7 | 10 | def get_template_sources(template_name, template_dirs=None): |
| 8 | 11 | if not template_dirs: |
| 9 | 12 | template_dirs = settings.TEMPLATE_DIRS |
| | 13 | is_absolute = os.path.isabs(template_name) |
| 10 | 14 | for template_dir in template_dirs: |
| | 15 | # When os.path.join encounters a component that is an absolute path, |
| | 16 | # all previous components are thrown away. That is not what we want |
| | 17 | # since os.path.join(['/template/dir/', '/etc/passwd'] -> '/etc/passwd' |
| | 18 | # So if the template_name given is an absolute path, only return it if |
| | 19 | # it is under the template_dir directory. |
| | 20 | if is_absolute and not template_name.startswith(template_dir): |
| | 21 | continue |
| 11 | 22 | yield os.path.join(template_dir, template_name) |
| 12 | 23 | |
| 13 | 24 | def load_template_source(template_name, template_dirs=None): |