diff options
| author | Przemysław Suliga <mail@suligap.net> | 2016-08-19 14:32:21 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-08-19 19:16:00 -0400 |
| commit | 1f68bb5683608ebe1ce47f0c9d37dad9482d1df9 (patch) | |
| tree | 7882a425ade1cb5cc852d7c890f4409f67629bd9 /django | |
| parent | 549b90fab33c80d1ba6575d4837ea52d79f70fb1 (diff) | |
Refs #26902 -- Protected against insecure redirects in set_language().
Diffstat (limited to 'django')
| -rw-r--r-- | django/views/i18n.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/django/views/i18n.py b/django/views/i18n.py index b3aaccbd33..a6bf8bcff4 100644 --- a/django/views/i18n.py +++ b/django/views/i18n.py @@ -37,11 +37,12 @@ def set_language(request): any state. """ next = request.POST.get('next', request.GET.get('next')) - if (next or not request.is_ajax()) and not is_safe_url(url=next, host=request.get_host()): + if ((next or not request.is_ajax()) and + not is_safe_url(url=next, host=request.get_host(), require_https=request.is_secure())): next = request.META.get('HTTP_REFERER') if next: next = urlunquote(next) # HTTP_REFERER may be encoded. - if not is_safe_url(url=next, host=request.get_host()): + if not is_safe_url(url=next, host=request.get_host(), require_https=request.is_secure()): next = '/' response = http.HttpResponseRedirect(next) if next else http.HttpResponse(status=204) if request.method == 'POST': |
