From e4beaf0371bf1e629117341819148b31e5feb530 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 24 Apr 2011 14:29:31 +0200 Subject: [PATCH] Strip links to local node, leaving only the keys (or an invalid link). This fixes #175. --- .../java/net/pterodactylus/sone/text/FreenetLinkParser.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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@"); -- 2.7.4