linkedin / URL-Detector

A Java library to detect and normalize URLs in text
783 stars 186 forks source link

StringIndexOutOfBoundsException on particular string #16

Open davidtinker opened 7 years ago

davidtinker commented 7 years ago

This string (excluding the double quotes) triggers a StringIndexOutOfBoundsException: "://VIVE MARINE LE PEN//:@."

java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.AbstractStringBuilder.substring(AbstractStringBuilder.java:908) ~[na:1.8.0_60]
    at java.lang.StringBuilder.substring(StringBuilder.java:76) ~[na:1.8.0_60]
    at java.lang.AbstractStringBuilder.substring(AbstractStringBuilder.java:854) ~[na:1.8.0_60]
    at java.lang.StringBuilder.substring(StringBuilder.java:76) ~[na:1.8.0_60]
    at com.linkedin.urls.detection.UrlDetector.readDefault(UrlDetector.java:191) ~[url-detector-0.1.17.jar!/:na]
    at com.linkedin.urls.detection.UrlDetector.detect(UrlDetector.java:142) ~[url-detector-0.1.17.jar!/:na]
BenEast commented 7 years ago

Hi David,

I'm going to look into resolving this issue. I'll submit a pull request when I've duplicated the issue and resolved it.

pgalbraith commented 6 years ago

Until this repo is published again, I have this fix included in a separate published build as io.github.pgalbraith:url-detector:0.1.18

https://github.com/pgalbraith/URL-Detector/releases/tag/url-detector-0.1.18