Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#16322 closed Bug (fixed)

Some mobile Accept-Language headers are not parsed

Reported by: Max Arnold <lwarxx@…> Owned by: nobody
Component: Internationalization Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


Some mobile phones use spaces before or after semicolon in Accept-Language header. Django can't parse such headers:

"Accept-Language: en; q=1.0, *; q=0.5"
"Accept-Language: ru-ru,*; q=0.5"
>>> parse_accept_lang_header('en; q=1.0, *; q=0.5')
>>> []

More examples here:

Another confirmation:

According to RFC 2616, there should be no whitespaces, but RFC 3282 allows CFWS and also I found this proposal where OWS is explicitly mentioned.

Attachments (1)

allow-spaces-in-accept-language.diff (1.7 KB) - added by Max Arnold <lwarxx@…> 8 years ago.
patch with tests

Download all attachments as: .zip

Change History (5)

comment:1 Changed 8 years ago by Aymeric Augustin

Easy pickings: set
Needs tests: set
Triage Stage: UnreviewedAccepted

Changed 8 years ago by Max Arnold <lwarxx@…>

patch with tests

comment:2 Changed 8 years ago by mark.smith@…

Has patch: set
Needs tests: unset
Triage Stage: AcceptedReady for checkin

comment:3 Changed 8 years ago by Jannis Leidel

Resolution: fixed
Status: newclosed

In [16457]:

Fixed #16322 -- Fixed Accept-Language parsing to allow spaces around semicolons. Thanks, Max Arnold.

comment:4 Changed 8 years ago by anonymous

Thank you too!

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