Prevent crash on more invalid links.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 7 Jan 2011 21:48:02 +0000 (22:48 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 7 Jan 2011 21:48:02 +0000 (22:48 +0100)
src/main/java/net/pterodactylus/sone/text/FreenetLinkParser.java

index fe602c6..63f68b8 100644 (file)
@@ -169,7 +169,7 @@ public class FreenetLinkParser implements Parser<FreenetLinkParserContext> {
                                                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. */