fix for url normalization (no backpath resolving in post parameters)

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7632 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 14 years ago
parent 0430a94eaa
commit 41b8d7f655

@ -64,6 +64,7 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
public static final int TLD_any_zone_filter = 255; // from TLD zones can be filtered during search; this is the catch-all filter public static final int TLD_any_zone_filter = 255; // from TLD zones can be filtered during search; this is the catch-all filter
private static final Pattern backPathPattern = Pattern.compile("(/[^/]+(?<!/\\.{1,2})/)[.]{2}(?=/|$)|/\\.(?=/)|/(?=/)"); private static final Pattern backPathPattern = Pattern.compile("(/[^/]+(?<!/\\.{1,2})/)[.]{2}(?=/|$)|/\\.(?=/)|/(?=/)");
private static final Pattern patternQuestion = Pattern.compile("\\?");
private static final Pattern patternDot = Pattern.compile("\\."); private static final Pattern patternDot = Pattern.compile("\\.");
private static final Pattern patternSlash = Pattern.compile("/"); private static final Pattern patternSlash = Pattern.compile("/");
private static final Pattern patternBackSlash = Pattern.compile("\\\\"); private static final Pattern patternBackSlash = Pattern.compile("\\\\");
@ -410,8 +411,11 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
public static final String resolveBackpath(final String path) { public static final String resolveBackpath(final String path) {
String p = path; String p = path;
if (p.length() == 0 || p.charAt(0) != '/') { p = "/" + p; } if (p.length() == 0 || p.charAt(0) != '/') { p = "/" + p; }
Matcher qm = patternQuestion.matcher(p); // do not resolve backpaths in the post values
int end = qm.find() ? qm.start() : p.length();
final Matcher matcher = backPathPattern.matcher(p); final Matcher matcher = backPathPattern.matcher(p);
while (matcher.find()) { while (matcher.find()) {
if (matcher.start() > end) break;
p = matcher.replaceAll(""); p = matcher.replaceAll("");
matcher.reset(p); matcher.reset(p);
} }

Loading…
Cancel
Save