Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public static void decode(final StringBuilder buffer, final int offset, final in
boolean ipv6Host = false;
for (; count > 0; count--, index++) {
final char ch = buffer.charAt(index);
if (ch == '[') {
if (ch == '[' && buffer.substring(0, index).matches("\\w+://([^/]+@)?")) {
ipv6Host = true;
}
if (ch == ']') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ public void testIPv6CheckUriEncoding() throws FileSystemException {
UriParser.checkUriEncoding("http://[fe80::14b5:1204:5410:64ca%en1]:8080");
}

@Test
public void testBracketUriDecoding() throws FileSystemException {
assertEquals("http://[fe80::14b5:1204:5410:64ca%en1]:8080", UriParser.decode("http://[fe80::14b5:1204:5410:64ca%en1]:8080"));
assertEquals("http://username@[fe80::14b5:1204:5410:64ca%en1]:8080", UriParser.decode("http://username@[fe80::14b5:1204:5410:64ca%en1]:8080"));
assertEquals("file:/user/file [with brackets].txt", UriParser.decode("file:/user/file%20[with%20brackets].txt"));
}

@Test
public void testNormalScheme() {
assertEquals("ftp", UriParser.extractScheme(schemes, "ftp://user:pass@host/some/path/some:file"));
Expand Down