FULL PRODUCT VERSION :
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-1~bpo8+1-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux kryten 4.9.0-0.bpo.3-amd64 #1 SMP Debian 4.9.25-1~bpo8+1 (2017-05-19) x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The URI parser in class java.net.URI only allows alphanumeric characters and "_." in scope_id portion of an IPv6 URI. See the definition of L_SCOPE_ID in the following file:
http://hg.openjdk.java.net/jdk/jdk/file/f29637bb390e/src/java.base/share/classes/java/net/URI.java
Both Android and Linux create interface names that contains "-", for example, "p2p-p2p-24" is a valid interface name on Android. The parser in java.net.URI will incorrectly reject such interface names when used in scope_id.
This is a bug according to RFC 6874 which says that the zone_id (scope_id) component can contain all characters from the unreserved class defined in RFC3986. RFC3986 defines the unreserved class as follows:
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the following code:
URI u = new URI("https://[fe80::78cc:a388:1931:01ed%p2p-p2p0-24]:10000/net");
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expected the parser would correctly parse the above HTTPS URL.
ACTUAL -
Exception in thread "main" java.net.URISyntaxException: Illegal character in scope id at index 38: https://[fe80::78cc:a3
88:1931:01ed%p2p-p2p0-24]:10000/net
at java.net.URI$Parser.fail(URI.java:2848)
at java.net.URI$Parser.checkChars(URI.java:3021)
at java.net.URI$Parser.parseServer(URI.java:3223)
at java.net.URI$Parser.parseAuthority(URI.java:3155)
at java.net.URI$Parser.parseHierarchical(URI.java:3097)
at java.net.URI$Parser.parse(URI.java:3053)
at java.net.URI.<init>(URI.java:588)
at Main.main(Main.java:12)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
See above.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
URI u = new URI("https://[fe80::78cc:a388:1931:01ed%p2p-p2p0-24]:10000/net");
}
}
---------- END SOURCE ----------
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-1~bpo8+1-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux kryten 4.9.0-0.bpo.3-amd64 #1 SMP Debian 4.9.25-1~bpo8+1 (2017-05-19) x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The URI parser in class java.net.URI only allows alphanumeric characters and "_." in scope_id portion of an IPv6 URI. See the definition of L_SCOPE_ID in the following file:
http://hg.openjdk.java.net/jdk/jdk/file/f29637bb390e/src/java.base/share/classes/java/net/URI.java
Both Android and Linux create interface names that contains "-", for example, "p2p-p2p-24" is a valid interface name on Android. The parser in java.net.URI will incorrectly reject such interface names when used in scope_id.
This is a bug according to RFC 6874 which says that the zone_id (scope_id) component can contain all characters from the unreserved class defined in RFC3986. RFC3986 defines the unreserved class as follows:
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the following code:
URI u = new URI("https://[fe80::78cc:a388:1931:01ed%p2p-p2p0-24]:10000/net");
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expected the parser would correctly parse the above HTTPS URL.
ACTUAL -
Exception in thread "main" java.net.URISyntaxException: Illegal character in scope id at index 38: https://[fe80::78cc:a3
88:1931:01ed%p2p-p2p0-24]:10000/net
at java.net.URI$Parser.fail(URI.java:2848)
at java.net.URI$Parser.checkChars(URI.java:3021)
at java.net.URI$Parser.parseServer(URI.java:3223)
at java.net.URI$Parser.parseAuthority(URI.java:3155)
at java.net.URI$Parser.parseHierarchical(URI.java:3097)
at java.net.URI$Parser.parse(URI.java:3053)
at java.net.URI.<init>(URI.java:588)
at Main.main(Main.java:12)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
See above.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
URI u = new URI("https://[fe80::78cc:a388:1931:01ed%p2p-p2p0-24]:10000/net");
}
}
---------- END SOURCE ----------