From: David ‘Bombe’ Roden Date: Fri, 7 Jan 2011 21:48:02 +0000 (+0100) Subject: Prevent crash on more invalid links. X-Git-Tag: 0.3.6.5^2~4 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=cac2acb6c092c157f055550443f98dbc8ecfdb20;p=Sone.git Prevent crash on more invalid links. --- diff --git a/src/main/java/net/pterodactylus/sone/text/FreenetLinkParser.java b/src/main/java/net/pterodactylus/sone/text/FreenetLinkParser.java index fe602c6..63f68b8 100644 --- a/src/main/java/net/pterodactylus/sone/text/FreenetLinkParser.java +++ b/src/main/java/net/pterodactylus/sone/text/FreenetLinkParser.java @@ -169,7 +169,7 @@ public class FreenetLinkParser implements Parser { if ((linkType == LinkType.SSK) || (linkType == LinkType.USK)) { try { new FreenetURI(link); - fromPostingSone = link.substring(4, 47).equals(context.getPostingSone().getId()); + fromPostingSone = link.substring(4, Math.min(link.length(), 47)).equals(context.getPostingSone().getId()); parts.add(fromPostingSone ? createTrustedFreenetLinkPart(link, name) : createFreenetLinkPart(link, name)); } catch (MalformedURLException mue1) { /* it’s not a valid link. */