Don't interpret very long strings.with.dots.like.this to be interpreted as URIs

This commit is contained in:
Sean Owen 2016-07-08 15:21:18 +01:00
parent 7e2d7c0b21
commit d3dd1827ba
3 changed files with 5 additions and 4 deletions

View file

@ -31,7 +31,7 @@ public final class URIResultParser extends ResultParser {
// See http://www.ietf.org/rfc/rfc2396.txt
private static final Pattern URL_WITH_PROTOCOL_PATTERN = Pattern.compile("[a-zA-Z][a-zA-Z0-9+-.]+:");
private static final Pattern URL_WITHOUT_PROTOCOL_PATTERN = Pattern.compile(
"([a-zA-Z0-9\\-]+\\.)+[a-zA-Z]{2,}" + // host name elements
"([a-zA-Z0-9\\-]+\\.){1,6}[a-zA-Z]{2,}" + // host name elements; allow up to say 6 domain elements
"(:\\d{1,5})?" + // maybe port
"(/|\\?|$)"); // query, path or nothing

View file

@ -61,6 +61,7 @@ public final class URIParsedResultTestCase extends Assert {
doTestNotUri("http://google.com?q=foo bar");
doTestNotUri("12756.501");
doTestNotUri("google.50");
doTestNotUri("foo.bar.bing.baz.foo.bar.bing.baz");
}
@Test

View file

@ -183,7 +183,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.0</version>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
@ -301,7 +301,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.1</version>
<version>3.0.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -494,7 +494,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.10</version>
<version>1.11</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>