encode invalid URI characters instead of removing them
@@ -88,7 +88,7 @@ public class URIFormatter {
}
public static String normalizeUri(String inputUri) {
-
+ //System.out.print("Normalize:" + inputUri + " = ");
boolean foundIssue = false;
StringBuilder sb = new StringBuilder();
@@ -102,7 +102,7 @@ public class URIFormatter {
foundIssue = true;
sb.append(inputUri.substring(0, i));
}
-
+ sb.append("%20");
continue;
}
else if(value == ',' || value == '`' || value == '\'' )
@@ -112,10 +112,12 @@ public class URIFormatter {
foundIssue = true;
sb.append(inputUri.substring(0, i));
}
- else
- {
- sb.append('_');
- }
+ if(value == ',')
+ sb.append("%2C");
+ else if (value == '`')
+ sb.append("%60");
+ else if (value == '\'')
+ sb.append("%27");
}
else
{
@@ -127,10 +129,12 @@ public class URIFormatter {
}
if(foundIssue)
{
+ //System.out.println(sb.toString());
return sb.toString();
}
else
{
+ //System.out.println(inputUri);
return inputUri;
}
}
