Opened 4 years ago

Closed 4 years ago

#21458 closed Bug (fixed)

Encoding error on /jsi18n/?language=ü

Reported by: Sergey Sorokin <40inss@…> Owned by: nobody
Component: Internationalization Version: master
Severity: Normal Keywords: UnicodeEncodeError, i18n, jsi18n
Cc: Baptiste Mispelon Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


When I pass utf-8 symbols in url /jsi18n/?language=ü, I get error:

UnicodeEncodeError at /jsi18n/
'ascii' codec can't encode character u'\xfc' in position 0: ordinal not in range(128)

There is the similar error (django 1.6, django/utils/translation/, line 357), when I try to pass encoded symbols: /jsi18n/?language=%00%27:

TypeError at /jsi18n/
must be encoded string without NULL bytes, not unicode

It's better to catch this exception and do not throw HTTP 500 error.

Change History (4)

comment:1 Changed 4 years ago by Baptiste Mispelon

Cc: Baptiste Mispelon added
Triage Stage: UnreviewedAccepted
Version: 1.6master


I can reproduce both errors (the first one only under Python 2).

From the looks of it, there's a similar bug in the set_language view as well.

comment:2 Changed 4 years ago by Baptiste Mispelon

Has patch: set

comment:3 Changed 4 years ago by Bouke Haarsma

Triage Stage: AcceptedReady for checkin

Patch is good to go.

comment:4 Changed 4 years ago by Baptiste Mispelon <bmispelon@…>

Resolution: fixed
Status: newclosed

In 8f5a688d00f2f73a0913acb04247322f13e2c971:

Fixed #21458 -- Made check_for_language more resistant to malformed input.

Thanks to Sergey Sorokin for the report and to Bouke Haarsma for the review.

Note: See TracTickets for help on using tickets.
Back to Top