Opened 4 years ago

Closed 4 years ago

Last modified 4 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

Description

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: http://stackoverflow.com/questions/377864/detect-mobile-supported-languages

Another confirmation: https://www-304.ibm.com/support/docview.wss?uid=swg1PK98260&wv=1

According to RFC 2616, there should be no whitespaces, but RFC 3282 allows CFWS and also I found this proposal http://lists.w3.org/Archives/Public/ietf-http-wg/2009OctDec/0177.html where OWS is explicitly mentioned.

Attachments (1)

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

Download all attachments as: .zip

Change History (5)

comment:1 Changed 4 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 4 years ago by Max Arnold <lwarxx@…>

patch with tests

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

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

comment:3 Changed 4 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 4 years ago by anonymous

Thank you too!

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