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 authored and James Valleroy committed 2019-09-04 21:27:17 -04:00
1 parent 8266d61192
commit 7dbdb8037a
1 file changed
+2 -1
+2 -1
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')