diff --git a/core/src/main/java/com/google/zxing/client/result/URIResultParser.java b/core/src/main/java/com/google/zxing/client/result/URIResultParser.java index 2b0feefa4..852f39c16 100644 --- a/core/src/main/java/com/google/zxing/client/result/URIResultParser.java +++ b/core/src/main/java/com/google/zxing/client/result/URIResultParser.java @@ -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 diff --git a/core/src/test/java/com/google/zxing/client/result/URIParsedResultTestCase.java b/core/src/test/java/com/google/zxing/client/result/URIParsedResultTestCase.java index 68d25194e..0a7e43c1b 100644 --- a/core/src/test/java/com/google/zxing/client/result/URIParsedResultTestCase.java +++ b/core/src/test/java/com/google/zxing/client/result/URIParsedResultTestCase.java @@ -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 diff --git a/pom.xml b/pom.xml index 909414ab1..4141b6864 100644 --- a/pom.xml +++ b/pom.xml @@ -183,7 +183,7 @@ org.apache.maven.plugins maven-source-plugin - 3.0.0 + 3.0.1 attach-sources @@ -301,7 +301,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.0.1 + 3.0.2 org.apache.maven.plugins @@ -494,7 +494,7 @@ org.codehaus.mojo build-helper-maven-plugin - 1.10 + 1.11 org.codehaus.mojo