#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: bmispelon 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 Changed 17 months ago by bmispelon

  • Cc bmispelon added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Version changed from 1.6 to master

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 Changed 17 months ago by bmispelon

  • Has patch set

comment:3 Changed 17 months ago by bouke

  • Triage Stage changed from Accepted to Ready for checkin

Patch is good to go.

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

  • Resolution set to fixed
  • Status changed from new to closed

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