Skip to content

Commit

Permalink
BUGFIX for regular expression
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1261 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
borg-0300 committed Dec 28, 2005
1 parent 106cd29 commit 8eb4181
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion source/de/anomic/htmlFilter/htmlFilterContentScraper.java
Expand Up @@ -164,14 +164,18 @@ public static String urlNormalform(URL url) {

// (this is different from previous normal forms where a '/' must not appear in root paths; here it must appear. Makes everything easier.)
if (path.length() == 0 || path.charAt(0) != '/') path = "/" + path;

Pattern pathPattern = Pattern.compile("(/[^/\\.]+/)[.]{2}(?=/)|/\\.(?=/)|/(?=/)");
Matcher matcher = pathPattern.matcher(path);
while (matcher.find()) {
path = matcher.replaceAll("");
matcher.reset(path);
}

while (path.startsWith("/../")) {
path = path.substring(3);
}

if (defaultPort) return url.getProtocol() + "://" + url.getHost() + path;
return url.getProtocol() + "://" + url.getHost() + ":" + url.getPort() + path;
}
Expand Down

0 comments on commit 8eb4181

Please sign in to comment.