Ross Poulton avatar Ross Poulton committed 864b143 Draft

Implement fix for #54 - "ValueError: too many values to unpack"
Uses fix from @ramusus, https://bitbucket.org/benoitc/django-authopenid/issue/54/type-subtype-parts-0-split-valueerror-too

Comments (0)

Files changed (1)

django_authopenid/utils/mimeparse.py

 
        ('application', 'xhtml', {'q', '0.5'})
        """
-    parts = mime_type.split(";")
-    params = dict([tuple([s.strip() for s in param.split("=")])\
-            for param in parts[1:] ])
-    (type, subtype) = parts[0].split("/")
+    import re
+    parts = re.split(r'[,|;]', mime_type)
+    params = dict([tuple([s.strip() for s in param.split("=")]) for param in parts[1:] if param.count("=")])
+    (type, subtype) = parts[0].split("/") if parts[0].count("/") else (parts[0], parts[0])
     return (type.strip(), subtype.strip(), params)
 
 def parse_media_range(range):
             # match using a wildcard for both requested and supported 
             self.assertEqual(best_match(mime_types_supported, 'image/*'), 'image/*')
 
-    unittest.main() 
+    unittest.main() 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.