From 5e68451a0e8b3f7175ff3f5330fb356d098e53d4 Mon Sep 17 00:00:00 2001 From: "Michael[tm] Smith" Date: Mon, 10 Nov 2014 03:22:46 +0900 Subject: [PATCH 1/2] Fixed handling of Unicode chars in userinfo. --- src/main/java/io/mola/galimatias/URLParser.java | 5 +++-- src/test/resources/data/urltestdata_whatwg.txt | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/mola/galimatias/URLParser.java b/src/main/java/io/mola/galimatias/URLParser.java index 6ef8ad3..263dcf5 100644 --- a/src/main/java/io/mola/galimatias/URLParser.java +++ b/src/main/java/io/mola/galimatias/URLParser.java @@ -517,8 +517,9 @@ else if (c == '#') { } atFlag = true; - for (int i = 0; i < buffer.length(); i++) { - final char otherChar = buffer.charAt(i); + + for (int i = 0; i < buffer.codePointCount(0, buffer.length()); i++) { + final int otherChar = buffer.codePointAt(i); if ( otherChar == 0x0009 || otherChar == 0x000A || diff --git a/src/test/resources/data/urltestdata_whatwg.txt b/src/test/resources/data/urltestdata_whatwg.txt index c9e7de7..3e64a13 100644 --- a/src/test/resources/data/urltestdata_whatwg.txt +++ b/src/test/resources/data/urltestdata_whatwg.txt @@ -324,3 +324,8 @@ feed:https://example.com/rss.xml s:feed p:https://example.com/rss.xml ed2k://|file|The_Two_Towers-The_Purist_Edit-Trailer.avi|14997504|965c013e991ee246d63d45ea71954c4d|/|sources,202.89.123.6:4662|/ s:ed2k p://|file|The_Two_Towers-The_Purist_Edit-Trailer.avi|14997504|965c013e991ee246d63d45ea71954c4d|/|sources,202.89.123.6:4662|/ magnet:?xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C s:magnet p: q:?xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C mailto:user@example.com s:mailto p:user@example.com + +-- +-- Misc Unicode +-- +http://foo:\uD83D\uDCA9@example.com/bar s:http h:example.com p:/bar u:foo pass:%F%9F%92%A9 From 6dd16d52b01f38b4ee18afff4d4f3785ea0a80fb Mon Sep 17 00:00:00 2001 From: "Michael[tm] Smith" Date: Mon, 10 Nov 2014 10:04:17 +0900 Subject: [PATCH 2/2] Fixed typo. --- src/test/resources/data/urltestdata_whatwg.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/data/urltestdata_whatwg.txt b/src/test/resources/data/urltestdata_whatwg.txt index 3e64a13..bb135c8 100644 --- a/src/test/resources/data/urltestdata_whatwg.txt +++ b/src/test/resources/data/urltestdata_whatwg.txt @@ -328,4 +328,4 @@ mailto:user@example.com s:mailto p:user@example.com -- -- Misc Unicode -- -http://foo:\uD83D\uDCA9@example.com/bar s:http h:example.com p:/bar u:foo pass:%F%9F%92%A9 +http://foo:\uD83D\uDCA9@example.com/bar s:http h:example.com p:/bar u:foo pass:%F0%9F%92%A9