incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prachida...@apache.org
Subject [5/8] git commit: refs/heads/4.1 - CLOUDSTACK-1125: [EC2 Query API] Permission denied exception when a parameter value contains space
Date Tue, 12 Feb 2013 23:10:28 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/e5bb55c5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/e5bb55c5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/e5bb55c5

Branch: refs/heads/4.1
Commit: e5bb55c5a398b7f04b9adba80f49d9e937574eb7
Parents: c06a16c
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 15:08:16 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/e5bb55c5/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