Projet

Général

Profil

0003-utils-allow-string-replacement-in-next-parameters-32.patch

Benjamin Dauvergne, 10 avril 2019 16:49

Télécharger (1,28 ko)

Voir les différences:

Subject: [PATCH 3/5] utils: allow string replacement in next parameters
 (#32140)

The caller must explicitely give the replacement it covers through the
replace argument taking a dictionnary. The dictionnary keys are the
replacement pattern as simple strings, dictionnary values are the
replacement substitution. The replacement substitution is encoded with
urlparse.quote() before replacement.
 src/authentic2/utils.py | 3 +++
 1 file changed, 3 insertions(+)
src/authentic2/utils.py
907 907
    '''Select the first valid next URL'''
908 908
    next_url = (include_post and get_next_url(request.POST, field_name=field_name)) or get_next_url(request.GET, field_name=field_name)
909 909
    if good_next_url(request, next_url):
910
        if replace:
911
            for key, value in replace.items():
912
                next_url = next_url.replace(key, urlparse.quote(value))
910 913
        return next_url
911 914
    return default
912 915

  
913
-