Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #21078 -- Handled additional bad Accept-Language header

  • Loading branch information...
commit a52cc1c0888c2cedb07b2c0619c1a92a2f6e2c40 1 parent 910a576
@jgmize jgmize authored timgraham committed
Showing with 5 additions and 1 deletion.
  1. +4 −1 django/utils/translation/trans_real.py
  2. +1 −0  tests/i18n/tests.py
View
5 django/utils/translation/trans_real.py
@@ -668,7 +668,10 @@ def parse_accept_lang_header(lang_string):
if first:
return []
if priority:
- priority = float(priority)
+ try:
+ priority = float(priority)
+ except ValueError:
+ return []
if not priority: # if priority is 0.0 at this point make it 1.0
priority = 1.0
result.append((lang, priority))
View
1  tests/i18n/tests.py
@@ -849,6 +849,7 @@ def test_parse_spec_http_header(self):
self.assertEqual([], p('de;q=0.a'))
self.assertEqual([], p('12-345'))
self.assertEqual([], p(''))
+ self.assertEqual([], p('en; q=1,'))
def test_parse_literal_http_header(self):
"""
Please sign in to comment.
Something went wrong with that request. Please try again.