Issue 76: properly address UTF encoding of paths

git-svn-id: http://jclouds.googlecode.com/svn/trunk@1843 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-08-09 22:41:55 +00:00
parent 6f58f153b5
commit 44eed3917f
1 changed files with 14 additions and 11 deletions

View File

@ -532,14 +532,18 @@ public class JaxrsAnnotationProcessor {
for (Entry<Integer, Set<Annotation>> entry : indexToPathParam.entrySet()) { for (Entry<Integer, Set<Annotation>> entry : indexToPathParam.entrySet()) {
for (Annotation key : entry.getValue()) { for (Annotation key : entry.getValue()) {
Set<Annotation> extractors = indexToParamExtractor.get(entry.getKey()); Set<Annotation> extractors = indexToParamExtractor.get(entry.getKey());
String paramKey = ((PathParam) key).value();
String paramValue;
if (extractors != null && extractors.size() > 0) { if (extractors != null && extractors.size() > 0) {
ParamParser extractor = (ParamParser) extractors.iterator().next(); ParamParser extractor = (ParamParser) extractors.iterator().next();
pathParamValues.put(((PathParam) key).value(), injector.getInstance( paramValue = injector.getInstance(extractor.value()).apply(args[entry.getKey()]);
extractor.value()).apply(args[entry.getKey()]));
} else { } else {
String paramKey = ((PathParam) key).value(); paramValue = args[entry.getKey()].toString();
String paramValue = URLEncoder.encode(args[entry.getKey()].toString(), "UTF-8"); }
paramValue = URLEncoder.encode(paramValue, "UTF-8");
// Web browsers do not always handle '+' characters well, use the well-supported
// '%20' instead.
paramValue = paramValue.replaceAll("\\+", "%20");
for (char c : skipEncode) { for (char c : skipEncode) {
String value = Character.toString(c); String value = Character.toString(c);
String encoded = URLEncoder.encode(value, "UTF-8"); String encoded = URLEncoder.encode(value, "UTF-8");
@ -548,7 +552,6 @@ public class JaxrsAnnotationProcessor {
pathParamValues.put(paramKey, paramValue); pathParamValues.put(paramKey, paramValue);
} }
} }
}
return pathParamValues; return pathParamValues;
} }