RFR [7u6]: 7166896: DocumentBuilder.parse(String uri) is not IPv6 enabled. It throws MalformedURLException

Paul Sandoz paul.sandoz at oracle.com
Mon Jun 25 16:13:41 UTC 2012

Hi Joe,

What happens if there is a space character or other characters in the string that should be encoded ?


I suspect "escapeNonUSAscii" is slightly misleading, it should be really called something like "escapeCharactersInUriString".

Note that '[' and ']' are not valid URI characters outside of an IPv6 encoded address.


On Jun 23, 2012, at 1:09 AM, Joe Wang wrote:

> Hi,
> This is a patch to fix the IPv6 issue.
> In a previous patch to fix an issue with system id containing international characters, an extra character escaping was added so that any URL passed to the parser goes through method escapeNonUSAscii before it's used to construct an URL.
> However, literal IPv6 addresses are enclosed in square brackets. The escapeNonUSAscii encoded address will become unrecognizable to URL that would throw a java.net.MalformedURLException.  An address such as http://[fe80::la03:73ff:fead:f7b0]/note.xml is encoded as http://%5Bfe80::la03:73ff:fead:f7b0%5D/note.xml", resulting in java.net.MalformedURLException: For input string: ":la03:73ff:fead:f7b0%5D".
> This patch skips the encoding process and returns it as is if there're no non-ascii characters.
> webrev: http://cr.openjdk.java.net/~joehw/7u6/7166896/webrev/
> Please review.
> Thanks,
> Joe

More information about the core-libs-dev mailing list