Ticket #9579: safe_join_base_path_correction.patch

File safe_join_base_path_correction.patch, 985 bytes (added by gonzalodelgado, 6 years ago)

first patch for #9579

  • django/utils/_os.py

     
    1 from os.path import join, normcase, abspath, sep
     1from os.path import join, normcase, abspath, sep, curdir
    22from django.utils.encoding import force_unicode
    33
    44def safe_join(base, *paths):
     
    1313    # insensitive operating systems (like Windows).
    1414    base = force_unicode(base)
    1515    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))
    1819    base_path_len = len(base_path)
    1920    # Ensure final_path starts with base_path and that the next character after
    2021    # the final path is os.sep (or nothing, in which case final_path must be
Back to Top