RFR: 8272702: Resolving URI relative path with no / may lead to incorrect toString
Daniel Fuchs
dfuchs at openjdk.java.net
Wed Jun 1 14:19:33 UTC 2022
On Thu, 26 May 2022 09:18:56 GMT, KIRIYAMA Takuya <duke at openjdk.java.net> wrote:
> Consider an authority component without trailing "/" as a base URI. When resolving a relative path against this base URI, the resulting URI is a concatenated URI without "/".
> This behaviour should be fixed, which is rationalized by rfc3986#section-5.2.3.
> Could you review this fix?
Changes requested by dfuchs (Reviewer).
src/java.base/share/classes/java/net/URI.java line 2140:
> 2138: } else {
> 2139: sb.append("/");
> 2140: }
This is wrong as it will cause `URI.create("foo").resolve(URI.create("test"))` to return `"/test"` instead of `"test"`
-------------
PR: https://git.openjdk.java.net/jdk/pull/8899
More information about the net-dev
mailing list