#32345: i18n.set_language unquotes next_url and produces wrong url for url 
params
containing "&" character
--------------------------------------+------------------------------------
     Reporter:  Sebastian Kapunkt     |                    Owner:  nobody
         Type:  Bug                   |                   Status:  new
    Component:  Internationalization  |                  Version:  3.1
     Severity:  Normal                |               Resolution:
     Keywords:  i18n unquote          |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  1                     |                    UI/UX:  0
--------------------------------------+------------------------------------
Changes (by Johannes Maron):

 * cc: Johannes Maron (added)
 * easy:  0 => 1
 * stage:  Unreviewed => Accepted


Old description:

> When changing the language and the current URL parameter include a
> parameter value with an encoded  "&" like
>
> {{{
> ?paramter=some%20%26%20thing
> }}}
>
> the redirect response from ```set_langauge``` is
>
> {{{
> ?paramter=some%20&%20thing
> }}}
> where I would still expect the same URL from as in the beginning.
>
> I've written a Django test that shows this bug:
> {{{
> def test_set_language_url_params():
>     from django.test import RequestFactory
>     from django.views.i18n import set_language
>
>     rf = RequestFactory()
>     request = rf.post("", next="")
>     request.META['HTTP_REFERER'] =
> '/someurl/?paramter=some%20%26%20thing'
>
>     response = set_language(request)
>     assert response.url == '/someurl/?paramter=some%20%26%20thing'
> }}}

New description:

 When changing the language and the current URL parameter include a
 parameter value with an encoded  "&" like

 {{{
 ?paramter=some%20%26%20thing
 }}}

 the redirect response from `set_langauge` is

 {{{
 ?paramter=some%20&%20thing
 }}}
 where I would still expect the same URL from as in the beginning.

 I've written a Django test that shows this bug:
 {{{
 def test_set_language_url_params():
     from django.test import RequestFactory
     from django.views.i18n import set_language

     rf = RequestFactory()
     request = rf.post("", next="")
     request.META['HTTP_REFERER'] = '/someurl/?paramter=some%20%26%20thing'

     response = set_language(request)
     assert response.url == '/someurl/?paramter=some%20%26%20thing'
 }}}

--

Comment:

 After some serious digging, the bug was introduced here:
 
https://github.com/django/django/commit/9e3f141701b96b6974b3386f83dc76e70a41377d
 via #26466.
 The problem seems to be, that the URL is not properly parsed. The path and
 GET attributes needs to be handled differently for that to work.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32345#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/074.dd968d21087df6fe6c014835beffcf7b%40djangoproject.com.

Reply via email to