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

This commit is contained in:
Josh Mize 2013-09-09 11:48:56 -05:00 committed by Tim Graham
parent 910a5760f6
commit a52cc1c088
2 changed files with 5 additions and 1 deletions

View File

@ -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 File

@ -849,6 +849,7 @@ class MiscTests(TransRealMixin, TestCase):
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):
"""