Opened 5 years ago

Closed 5 years ago

Last modified 5 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@…> 5 years ago.
patch with tests

Download all attachments as: .zip

Change History (5)

comment:1 Changed 5 years ago by aaugustin

  • Easy pickings set
  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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

patch with tests

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

  • Has patch set
  • Needs tests unset
  • Triage Stage changed from Accepted to Ready for checkin

comment:3 Changed 5 years ago by jezdez

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

In [16457]:

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

comment:4 Changed 5 years ago by anonymous

Thank you too!

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