1
0
mirror of https://github.com/django/django.git synced 2025-10-29 08:36:09 +00:00

Added some better error reporting and path handling when creating template paths.

We now raise UnicodeDecodeError for non-UTF-8 bytestrings (thanks to Daniel
Pope for diagnosing this was being swallowed by ValueError) and allow UTF-8
bytestrings as template directories.

Refs #8965.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@9161 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick
2008-10-06 06:34:54 +00:00
parent fb62bcc69e
commit 8fb1459b52
4 changed files with 52 additions and 20 deletions

View File

@@ -1,4 +1,5 @@
from os.path import join, normcase, abspath, sep
from django.utils.encoding import force_unicode
def safe_join(base, *paths):
"""
@@ -10,6 +11,8 @@ def safe_join(base, *paths):
"""
# We need to use normcase to ensure we don't false-negative on case
# insensitive operating systems (like Windows).
base = force_unicode(base)
paths = [force_unicode(p) for p in paths]
final_path = normcase(abspath(join(base, *paths)))
base_path = normcase(abspath(base))
base_path_len = len(base_path)