cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [9/50] [abbrv] git commit: refs/heads/ui-plugins - CLOUDSTACK-1125: [EC2 Query API] Permission denied exception when a parameter value contains space
Date Wed, 13 Feb 2013 22:04:22 GMT
CLOUDSTACK-1125: [EC2 Query API] Permission denied exception when a parameter value contains
space

Convert space characters in the parameters to %20 while forming a query string after url-encode
because java.net.URLEncoder performs application/x-www-form-urlencoded-type encoding and not
percent-encoding. According to RFC 3986 as required by Amazon, we need to percent-encode.


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

Branch: refs/heads/ui-plugins
Commit: b0b2fd48336d7b7620fdb4ed9f20ca46bef81a19
Parents: c26b02a
Author: Likitha Shetty <Likitha.Shetty@citrix.com>
Authored: Tue Feb 12 13:56:19 2013 -0800
Committer: Prachi Damle <prachi@cloud.com>
Committed: Tue Feb 12 13:56:36 2013 -0800

----------------------------------------------------------------------
 .../com/cloud/bridge/service/EC2RestServlet.java   |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b0b2fd48/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java b/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java
index 5d151ba..b5296a4 100644
--- a/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java
+++ b/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java
@@ -1899,10 +1899,14 @@ public class EC2RestServlet extends HttpServlet {
                     String paramName = (String) params.nextElement();
                     // exclude the signature string obviously. ;)
                     if (paramName.equalsIgnoreCase("Signature")) continue;
+                    // URLEncoder performs application/x-www-form-urlencoded-type encoding
and not Percent encoding
+                    // according to RFC 3986 as required by Amazon, we need to Percent-encode
(URL Encode)
+                    String encodedValue = URLEncoder.encode(request.getParameter(paramName),
"UTF-8")
+                            .replace("+", "%20").replace("*", "%2A");
                     if (queryString == null) 
-                        queryString = paramName + "=" + URLEncoder.encode(request.getParameter(paramName),
"UTF-8"); 
+                        queryString = paramName + "=" + encodedValue;
                     else 
-                        queryString = queryString + "&" + paramName + "=" + URLEncoder.encode(request.getParameter(paramName),
"UTF-8"); 
+                        queryString = queryString + "&" + paramName + "=" + encodedValue;
                 }
             }
         }


Mime
View raw message