mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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.
This commit is contained in:
parent
c26b02a0a7
commit
b0b2fd4833
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user