summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSandro Covo <sandro@sandrocovo.ch>2021-01-12 22:19:53 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-01-29 12:37:48 +0100
commit0a3d93ffba6fa7ee39404c692c8874a8fae27ea8 (patch)
treee0912d8cf2ce5b7eaa8f368b7305f8f2d5c78a4e /tests
parent18cac6bbfb3cdc02d4891ad01d9f358cce96e86a (diff)
[3.2.x] Fixed #32345 -- Fixed preserving encoded query strings in set_language() view.
Thanks Johannes Maron for the review. Backport of 6822aa5c6c3fbec7c5393a05e990865ba59fe167 from master
Diffstat (limited to 'tests')
-rw-r--r--tests/view_tests/tests/test_i18n.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/view_tests/tests/test_i18n.py b/tests/view_tests/tests/test_i18n.py
index 84dff20753..bb17385a86 100644
--- a/tests/view_tests/tests/test_i18n.py
+++ b/tests/view_tests/tests/test_i18n.py
@@ -199,12 +199,14 @@ class SetLanguageTests(TestCase):
def test_setlang_decodes_http_referer_url(self):
"""
- The set_language view decodes the HTTP_REFERER URL.
+ The set_language view decodes the HTTP_REFERER URL and preserves an
+ encoded query string.
"""
# The URL & view must exist for this to work as a regression test.
self.assertEqual(reverse('with_parameter', kwargs={'parameter': 'x'}), '/test-setlang/x/')
lang_code = self._get_inactive_language_code()
- encoded_url = '/test-setlang/%C3%A4/' # (%C3%A4 decodes to ä)
+ # %C3%A4 decodes to ä, %26 to &.
+ encoded_url = '/test-setlang/%C3%A4/?foo=bar&baz=alpha%26omega'
response = self.client.post('/i18n/setlang/', {'language': lang_code}, HTTP_REFERER=encoded_url)
self.assertRedirects(response, encoded_url, fetch_redirect_response=False)
self.assertEqual(self.client.cookies[settings.LANGUAGE_COOKIE_NAME].value, lang_code)