views: Fix failure in redirecting from language selection page

is_safe_url() expects allowed_hosts argument instead of host. This is an
internal method. Found by reviewing the release notes for Django 2.0, 2.1 and
2.2. This should be final change needed for Django 2.2 support.

Closes: #1518.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2019-08-30 18:01:32 -07:00 committed by James Valleroy
parent 8266d61192
commit 7dbdb8037a
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -101,7 +101,8 @@ class LanguageSelectionView(FormView):
"""Return the URL in the next parameter or home page."""
redirect_to = self.request.GET.get(REDIRECT_FIELD_NAME, '')
redirect_to = self.request.POST.get(REDIRECT_FIELD_NAME, redirect_to)
if is_safe_url(url=redirect_to, host=self.request.get_host()):
if is_safe_url(url=redirect_to,
allowed_hosts={self.request.get_host()}):
return redirect_to
return reverse('index')