Ticket #17516: #17516-memoized_safe_join.diff
File #17516-memoized_safe_join.diff, 776 bytes (added by , 13 years ago) |
---|
-
django/utils/_os.py
import os 2 2 import stat 3 3 from os.path import join, normcase, normpath, abspath, isabs, sep 4 4 from django.utils.encoding import force_unicode 5 from django.utils.functional import memoize 6 7 _safe_join_cache = {} # Saves already safe-joined paths. 5 8 6 9 # Define our own abspath function that can handle joining 7 10 # unicode paths to a current working directory that has non-ASCII … … def safe_join(base, *paths): 45 48 raise ValueError('The joined path (%s) is located outside of the base ' 46 49 'path component (%s)' % (final_path, base_path)) 47 50 return final_path 51 safe_join = memoize(safe_join, _safe_join_cache, 10) 48 52 49 53 def rmtree_errorhandler(func, path, exc_info): 50 54 """