Skip to content
Browse files

Handles spaces and other url-encoded chars better.

Removed some old special-case handling code since the java URLDecoder works properly now.

Fixes EUCA-1779 and EUCA-2024
  • Loading branch information...
1 parent 5f459fe commit f6bc3b134d764cc5e8966193bf2d8d010fc876c1 Zach Hill committed Jul 27, 2012
View
2 clc/modules/core/src/main/java/com/eucalyptus/util/WalrusUtil.java
@@ -112,7 +112,7 @@ private static BaseMessage convertException( String correlationId, Throwable ex
}
public static String URLdecode(String objectKey) throws UnsupportedEncodingException {
- return URLDecoder.decode(objectKey, "UTF-8").replace("%20", "+").replace("%2A", "*").replace("~", "%7E").replace(" ", "+");
+ return URLDecoder.decode(objectKey, "UTF-8");
}
public static String[] getTarget(String operationPath) {
View
10 clc/modules/wsstack/src/main/java/com/eucalyptus/ws/handlers/WalrusRESTBinding.java
@@ -518,8 +518,8 @@ private String getOperation(MappingHttpRequest httpRequest, Map operationParams)
if(httpRequest.containsHeader(WalrusProperties.COPY_SOURCE.toString())) {
String copySource = httpRequest.getHeader(WalrusProperties.COPY_SOURCE.toString());
try {
- copySource = new URLCodec().decode(copySource);
- } catch(DecoderException ex) {
+ copySource = WalrusUtil.URLdecode(copySource);
+ } catch(UnsupportedEncodingException ex) {
throw new BindingException("Unable to decode copy source: " + copySource);
}
String[] sourceParts = copySource.split("\\?");
@@ -534,12 +534,8 @@ private String getOperation(MappingHttpRequest httpRequest, Map operationParams)
for(int i = 1; i < sourceTarget.length; ++i) {
sourceObjectKey += sourceSplitOn + sourceTarget[i];
sourceSplitOn = "/";
- }
- try {
- sourceObjectKey = WalrusUtil.URLdecode(sourceObjectKey);
- } catch (UnsupportedEncodingException e) {
- throw new BindingException("Unable to get source key: " + e.getMessage());
}
+
operationParams.put("SourceBucket", sourceTarget[0]);
operationParams.put("SourceObject", sourceObjectKey);
operationParams.put("DestinationBucket", operationParams.remove("Bucket"));

0 comments on commit f6bc3b1

Please sign in to comment.
Something went wrong with that request. Please try again.