crawling of filenames with + fails due to url decoding

modified UTF8.decodeURL to apply x-www-form-urlencoded ( space -> + ) to the query part of the url only.
pull/1/head
reger 11 years ago
parent 3b559e7846
commit 982601017e

@ -211,21 +211,32 @@ public class UTF8 implements Comparator<String> {
/**
* Decodes a <code>application/x-www-form-urlencoded</code> string using a specific
* encoding scheme.
* for url query part only application/x-www-form-urlencoded (+ -> space) is applied
*/
public static String decodeURL(final String s) {
boolean needToChange = false;
final int numChars = s.length();
final StringBuilder sb = new StringBuilder(numChars > 500 ? numChars / 2 : numChars);
int i = 0;
boolean insearchpart = false;
char c;
byte[] bytes = null;
while (i < numChars) {
c = s.charAt(i);
switch (c) {
case '+':
sb.append(' ');
case '?' : // mark start of query part (to start x-www-form-urlencoded)
sb.append(c);
i++;
insearchpart = true; // flag to start x-www-form + decoding
break;
case '+': //application/x-www-form-urlencoded (in searchpart)
if (insearchpart) {
sb.append(' ');
needToChange = true;
} else {
sb.append(c);
}
i++;
needToChange = true;
break;
case '%':
try {

Loading…
Cancel
Save