Anonymous avatar Anonymous committed 52b596d

graceful handling of unicode parameters

Comments (0)

Files changed (1)

hoptoad/api/htv1.py

 
 def _parse_request(request):
     """Return a request mapping for a notification from the given request."""
-    request_get = dict( (str(k), str(v)) for (k, v) in request.GET.items() )
-    request_post = dict( (str(k), str(v)) for (k, v) in request.POST.items() )
-    
-    data = request_post or request_get
+    data = []
+    for (k, v) in request.POST.items():
+        try:
+            data.append((str(k), str(v)))
+        except UnicodeEncodeError:
+            data.append((str(k), repr(v)))
+    if not data:
+        for (k, v) in request.GET.items():
+            try:
+                data.append((str(k), str(v)))
+            except UnicodeEncodeError:
+                data.append((str(k), repr(v)))
+    data = dict(data)
     for k in PROTECTED_PARAMS.intersection(data.keys()):
         data[k] = '********************'
     
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.