Issue 1157 support protocols ending with : not :// like bitcoin

git-svn-id: https://zxing.googlecode.com/svn/trunk@2178 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2012-02-11 10:25:43 +00:00
parent c39eb3a817
commit 6261912024
2 changed files with 6 additions and 1 deletions

View file

@ -32,7 +32,7 @@ public final class URIResultParser extends ResultParser {
"(:\\d{1,5})?" + // maybe port
"(/|\\?|$)"; // query, path or nothing
private static final Pattern URL_WITH_PROTOCOL_PATTERN = Pattern.compile(
"[a-zA-Z0-9]{2,}://" + // protocol
"[a-zA-Z0-9]{2,}:(/)*" + // protocol
"[a-zA-Z0-9\\-]+(\\.[a-zA-Z0-9\\-]+)*" + // host name elements
PATTERN_END);
private static final Pattern URL_WITHOUT_PROTOCOL_PATTERN = Pattern.compile(

View file

@ -88,6 +88,11 @@ public final class URIParsedResultTestCase extends Assert {
doTestIsPossiblyMalicious("http://google.com/@@", false);
}
@Test
public void testExotic() {
doTest("bitcoin:mySD89iqpmptrK3PhHFW9fa7BXiP7ANy3Y", "bitcoin:mySD89iqpmptrK3PhHFW9fa7BXiP7ANy3Y", null);
}
private static void doTest(String contents, String uri, String title) {
Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult);