Invalid/Potentially misbehaving reference URI implementation

Hello,
I have implemented part of my test cases using a smart fuzzer and I found a potential error in the reference implementation:

uri.tests.ValidTests.testFuzzy(ValidTests.java:93): ComparisonFailure: expected:<0[00.009.010.0]99> but was:<0[.9.10.]99>

By the URI specification, 000.009.010.099 is the host name and {0,9,10,99} are the corresponding bytes/octets, but the reference implementation removes the additional leading zeroes. This is an issue because when re-creating an URI from the parsed result, this results in an equivalent, but different URI.
It would be great if this behavior was documented.

PS: Don’t worry, my fuzzer only takes around 30ms to run :wink:

To quote the interface comments from IPv4Address:

	/**
	 * @return "a.b.c.d" where a-d are numbers from 0 to 255 without leading
	 *         zeros
	 */
	@Override
	public String toString();

The leading zeros are removed for IPv4.

1 Like