From: Calin Crisan Date: Sun, 8 Feb 2015 17:20:22 +0000 (+0200) Subject: another fix for the signature algorithm X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=f316af69cc279c0f0b9eaad558a6c7e2ade4bb54;p=motioneye-debian another fix for the signature algorithm --- diff --git a/src/utils.py b/src/utils.py index 502c4fc..eb120ab 100644 --- a/src/utils.py +++ b/src/utils.py @@ -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)