]> www.vanbest.org Git - motioneye-debian/commitdiff
another fix for the signature algorithm
authorCalin Crisan <ccrisan@gmail.com>
Sun, 8 Feb 2015 17:20:22 +0000 (19:20 +0200)
committerCalin Crisan <ccrisan@gmail.com>
Sun, 8 Feb 2015 17:20:22 +0000 (19:20 +0200)
src/utils.py

index 502c4fce9cdd7dac24e591d7281e95ec136d19d3..eb120abbb3d15f263e3a2a7309221c6a7ed81b53 100644 (file)
@@ -294,7 +294,9 @@ def compute_signature(method, uri, body, key):
     parts = list(urlparse.urlsplit(uri))
     query = [q for q in urlparse.parse_qsl(parts[3], keep_blank_values=True) if (q[0] != '_signature')]
     query.sort(key=lambda q: q[0])
-    query = urllib.urlencode(query)
+    # "safe" characters here are set to match the encodeURIComponent JavaScript counterpart
+    query = [(n, urllib.quote(v, safe="!'()*~")) for (n, v) in query]
+    query = '&'.join([(q[0] + '=' + q[1]) for q in query])
     parts[0] = parts[1] = ''
     parts[3] = query
     uri = urlparse.urlunsplit(parts)