Shorten a possible invalid link in a safer way.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 6 Jan 2011 13:39:33 +0000 (14:39 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 6 Jan 2011 13:39:33 +0000 (14:39 +0100)
src/main/java/net/pterodactylus/sone/text/FreenetLinkParser.java

index fbf87c8..b50113d 100644 (file)
@@ -178,7 +178,7 @@ public class FreenetLinkParser implements Parser {
                                                                        name = name.substring(name.lastIndexOf('/', name.lastIndexOf('/') - 1));
                                                                } else {
                                                                        /* shorten to 5 chars. */
-                                                                       name = name.substring(4, 9);
+                                                                       name = name.substring(4, Math.min(9, name.length()));
                                                                }
                                                        }
                                                }