Loading django/utils/translation/trans_real.py +2 −5 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ CONTEXT_SEPARATOR = "\x04" # and RFC 3066, section 2.1 accept_language_re = re.compile(r''' ([A-Za-z]{1,8}(?:-[A-Za-z0-9]{1,8})*|\*) # "en", "en-au", "x-y-z", "es-419", "*" (?:\s*;\s*q=(0(?:\.\d{,3})?|1(?:.0{,3})?))? # Optional "q=1.00", "q=0.8" (?:\s*;\s*q=(0(?:\.\d{,3})?|1(?:\.0{,3})?))? # Optional "q=1.00", "q=0.8" (?:\s*,\s*|$) # Multiple accepts per header. ''', re.VERBOSE) Loading Loading @@ -790,10 +790,7 @@ def parse_accept_lang_header(lang_string): if first: return [] if 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)) Loading tests/i18n/tests.py +2 −1 Original line number Diff line number Diff line Loading @@ -1317,6 +1317,7 @@ class MiscTests(SimpleTestCase): self.assertEqual([('*', 1.0)], p('*')) self.assertEqual([('de', 1.0)], p('de;q=0.')) self.assertEqual([('en', 1.0), ('*', 0.5)], p('en; q=1.0, * ; q=0.5')) self.assertEqual([('en', 1.0)], p('en; q=1,')) self.assertEqual([], p('')) # Bad headers; should always return []. Loading @@ -1336,7 +1337,7 @@ class MiscTests(SimpleTestCase): self.assertEqual([], p('de;q=0.a')) self.assertEqual([], p('12-345')) self.assertEqual([], p('')) self.assertEqual([], p('en; q=1,')) self.assertEqual([], p('en;q=1e0')) def test_parse_literal_http_header(self): """ Loading Loading
django/utils/translation/trans_real.py +2 −5 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ CONTEXT_SEPARATOR = "\x04" # and RFC 3066, section 2.1 accept_language_re = re.compile(r''' ([A-Za-z]{1,8}(?:-[A-Za-z0-9]{1,8})*|\*) # "en", "en-au", "x-y-z", "es-419", "*" (?:\s*;\s*q=(0(?:\.\d{,3})?|1(?:.0{,3})?))? # Optional "q=1.00", "q=0.8" (?:\s*;\s*q=(0(?:\.\d{,3})?|1(?:\.0{,3})?))? # Optional "q=1.00", "q=0.8" (?:\s*,\s*|$) # Multiple accepts per header. ''', re.VERBOSE) Loading Loading @@ -790,10 +790,7 @@ def parse_accept_lang_header(lang_string): if first: return [] if 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)) Loading
tests/i18n/tests.py +2 −1 Original line number Diff line number Diff line Loading @@ -1317,6 +1317,7 @@ class MiscTests(SimpleTestCase): self.assertEqual([('*', 1.0)], p('*')) self.assertEqual([('de', 1.0)], p('de;q=0.')) self.assertEqual([('en', 1.0), ('*', 0.5)], p('en; q=1.0, * ; q=0.5')) self.assertEqual([('en', 1.0)], p('en; q=1,')) self.assertEqual([], p('')) # Bad headers; should always return []. Loading @@ -1336,7 +1337,7 @@ class MiscTests(SimpleTestCase): self.assertEqual([], p('de;q=0.a')) self.assertEqual([], p('12-345')) self.assertEqual([], p('')) self.assertEqual([], p('en; q=1,')) self.assertEqual([], p('en;q=1e0')) def test_parse_literal_http_header(self): """ Loading