libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject git commit: Fix make_signature method in the CloudStack driver to correctly handle square brackets.
Date Fri, 07 Feb 2014 18:59:01 GMT
Updated Branches:
  refs/heads/trunk 595b6026f -> f9737893a


Fix make_signature method in the CloudStack driver to correctly handle square
brackets.


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/f9737893
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/f9737893
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/f9737893

Branch: refs/heads/trunk
Commit: f9737893a28c70e6b8e34da801ec88fa573d00b9
Parents: 595b602
Author: Tomaz Muraus <tomaz@apache.org>
Authored: Fri Feb 7 19:54:26 2014 +0100
Committer: Tomaz Muraus <tomaz@apache.org>
Committed: Fri Feb 7 19:54:26 2014 +0100

----------------------------------------------------------------------
 libcloud/common/cloudstack.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/f9737893/libcloud/common/cloudstack.py
----------------------------------------------------------------------
diff --git a/libcloud/common/cloudstack.py b/libcloud/common/cloudstack.py
index b6150f4..65810af 100644
--- a/libcloud/common/cloudstack.py
+++ b/libcloud/common/cloudstack.py
@@ -20,6 +20,7 @@ import hmac
 
 from libcloud.utils.py3 import httplib
 from libcloud.utils.py3 import urlencode
+from libcloud.utils.py3 import urlquote
 from libcloud.utils.py3 import b
 
 from libcloud.common.types import ProviderError
@@ -71,7 +72,16 @@ class CloudStackConnection(ConnectionUserAndKey, PollingConnection):
     def _make_signature(self, params):
         signature = [(k.lower(), v) for k, v in list(params.items())]
         signature.sort(key=lambda x: x[0])
-        signature = urlencode(signature)
+
+        pairs = []
+        for pair in signature:
+            key = urlquote(str(pair[0]), safe='[]')
+            value = urlquote(str(pair[1]), safe='[]')
+            item = '%s=%s' % (key, value)
+            pairs .append(item)
+
+        signature = '&'.join(pairs)
+
         signature = signature.lower().replace('+', '%20')
         signature = hmac.new(b(self.key), msg=b(signature),
                              digestmod=hashlib.sha1)


Mime
View raw message