Ticket #9579: safe_join_base_path_correction.patch
File safe_join_base_path_correction.patch, 985 bytes (added by , 16 years ago) |
---|
-
django/utils/_os.py
1 from os.path import join, normcase, abspath, sep 1 from os.path import join, normcase, abspath, sep, curdir 2 2 from django.utils.encoding import force_unicode 3 3 4 4 def safe_join(base, *paths): … … 13 13 # insensitive operating systems (like Windows). 14 14 base = force_unicode(base) 15 15 paths = [force_unicode(p) for p in paths] 16 final_path = normcase(abspath(join(base, *paths))) 17 base_path = normcase(abspath(base)) 16 abs_path = force_unicode(abspath(curdir)) 17 final_path = normcase(join(abs_path, join(base, *paths))) 18 base_path = normcase(join(abs_path, base)) 18 19 base_path_len = len(base_path) 19 20 # Ensure final_path starts with base_path and that the next character after 20 21 # the final path is os.sep (or nothing, in which case final_path must be