From: David ‘Bombe’ Roden Date: Sun, 24 Apr 2011 12:29:31 +0000 (+0200) Subject: Strip links to local node, leaving only the keys (or an invalid link). X-Git-Tag: 0.6.3^2~13 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=e4beaf0371bf1e629117341819148b31e5feb530;p=Sone.git Strip links to local node, leaving only the keys (or an invalid link). This fixes #175. --- diff --git a/src/main/java/net/pterodactylus/sone/text/FreenetLinkParser.java b/src/main/java/net/pterodactylus/sone/text/FreenetLinkParser.java index cea4452..0f6887d 100644 --- a/src/main/java/net/pterodactylus/sone/text/FreenetLinkParser.java +++ b/src/main/java/net/pterodactylus/sone/text/FreenetLinkParser.java @@ -127,6 +127,18 @@ public class FreenetLinkParser implements Parser { } emptyLines = 0; boolean lineComplete = true; + + /* filter http(s) links to own node. */ + String hostHeader = (context.getRequest() != null) ? context.getRequest().getHttpRequest().getHeader("host") : null; + logger.log(Level.FINEST, "hostHeader: %s", hostHeader); + if (hostHeader != null) { + for (String toRemove : new String[] { "http://" + hostHeader + "/", "https://" + hostHeader + "/", "http://" + hostHeader, "https://" + hostHeader }) { + while (line.indexOf(toRemove) != -1) { + line = line.replace(toRemove, ""); + } + } + } + while (line.length() > 0) { int nextKsk = line.indexOf("KSK@"); int nextChk = line.indexOf("CHK@");