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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user