cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [3/9] git commit: requester: remove double URL encoding, use urllib.quote instead of quote_plus
Date Fri, 31 Oct 2014 01:03:47 GMT
requester: remove double URL encoding, use urllib.quote instead of quote_plus

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


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

Branch: refs/heads/5.3
Commit: bbe01aae2adf438272d865d28dfc122c1b5dc914
Parents: 2660143
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Fri Oct 31 01:26:20 2014 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Fri Oct 31 01:26:20 2014 +0530

----------------------------------------------------------------------
 cloudmonkey/cloudmonkey.py |  4 ----
 cloudmonkey/requester.py   | 10 +++++-----
 2 files changed, 5 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/bbe01aae/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/cloudmonkey.py b/cloudmonkey/cloudmonkey.py
index 45e67c9..9950d0d 100644
--- a/cloudmonkey/cloudmonkey.py
+++ b/cloudmonkey/cloudmonkey.py
@@ -30,7 +30,6 @@ try:
     import sys
     import time
     import types
-    import urllib
 
     from cachemaker import loadcache, savecache, monkeycache, splitverbsubject
     from config import __version__, __description__, __projecturl__
@@ -370,9 +369,6 @@ class CloudMonkeyShell(cmd.Cmd, object):
         if 'asyncapis' in self.apicache:
             isasync = apiname in self.apicache['asyncapis']
 
-        for key in args_dict.keys():
-            args_dict[key] = urllib.quote(args_dict[key])
-
         result = self.make_request(apiname, args_dict, isasync)
 
         if not result:

http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/bbe01aae/cloudmonkey/requester.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/requester.py b/cloudmonkey/requester.py
index 08876c9..c935488 100644
--- a/cloudmonkey/requester.py
+++ b/cloudmonkey/requester.py
@@ -178,14 +178,14 @@ def make_request(command, args, logger, url,
     request = zip(args.keys(), args.values())
     request.sort(key=lambda x: x[0].lower())
 
-    request_url = "&".join(["=".join([r[0], urllib.quote_plus(str(r[1]))])
+    request_url = "&".join(["=".join([r[0], urllib.quote(unicode(r[1]))])
                            for r in request])
     hashStr = "&".join(["=".join([r[0].lower(),
-                       str.lower(urllib.quote_plus(str(r[1]))).replace("+",
-                       "%20")]) for r in request])
+                                  urllib.quote(unicode(r[1])).lower()])
+                                  for r in request])
 
-    sig = urllib.quote_plus(base64.encodestring(hmac.new(secretkey, hashStr,
-                            hashlib.sha1).digest()).strip())
+    sig = urllib.quote(base64.encodestring(hmac.new(secretkey, hashStr,
+                       hashlib.sha1).digest()).strip())
     request_url += "&signature=%s" % sig
     request_url = "%s?%s" % (url, request_url)
 


Mime
View raw message