Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit a52cc1c0888c2cedb07b2c0619c1a92a2f6e2c40 1 parent 910a576
Josh Mize authored September 09, 2013 timgraham committed September 09, 2013
5  django/utils/translation/trans_real.py
@@ -668,7 +668,10 @@ def parse_accept_lang_header(lang_string):
668 668
         if first:
669 669
             return []
670 670
         if priority:
671  
-            priority = float(priority)
  671
+            try:
  672
+                priority = float(priority)
  673
+            except ValueError:
  674
+                return []
672 675
         if not priority:        # if priority is 0.0 at this point make it 1.0
673 676
             priority = 1.0
674 677
         result.append((lang, priority))
1  tests/i18n/tests.py
@@ -849,6 +849,7 @@ def test_parse_spec_http_header(self):
849 849
         self.assertEqual([], p('de;q=0.a'))
850 850
         self.assertEqual([], p('12-345'))
851 851
         self.assertEqual([], p(''))
  852
+        self.assertEqual([], p('en; q=1,'))
852 853
 
853 854
     def test_parse_literal_http_header(self):
854 855
         """

0 notes on commit a52cc1c

Please sign in to comment.
Something went wrong with that request. Please try again.