Opened 11 years ago

Closed 11 years ago

#21458 closed Bug (fixed)

Encoding error on /jsi18n/?language=ü

Reported by: Sergey Sorokin <40inss@…> Owned by: nobody
Component: Internationalization Version: dev
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

Description

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/trans_real.py, 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 by Baptiste Mispelon, 11 years ago

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

Hi,

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 by Baptiste Mispelon, 11 years ago

Has patch: set

comment:3 by Bouke Haarsma, 11 years ago

Triage Stage: AcceptedReady for checkin

Patch is good to go.

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

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