jdk icon indicating copy to clipboard operation
jdk copied to clipboard

8272702: Resolving URI relative path with no / may lead to incorrect toString

Open tkiriyama opened this issue 3 years ago • 9 comments
trafficstars

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?


Progress

  • [x] Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • [x] Change must not contain extraneous whitespace
  • [x] Commit message must refer to an issue

Issue

  • JDK-8272702: Resolving URI relative path with no / may lead to incorrect toString

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/8899/head:pull/8899
$ git checkout pull/8899

Update a local copy of the PR:
$ git checkout pull/8899
$ git pull https://git.openjdk.org/jdk pull/8899/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 8899

View PR using the GUI difftool:
$ git pr show -t 8899

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/8899.diff

tkiriyama avatar May 26 '22 09:05 tkiriyama

:wave: Welcome back tkiriyama! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

bridgekeeper[bot] avatar May 26 '22 09:05 bridgekeeper[bot]

@tkiriyama The following label will be automatically applied to this pull request:

  • net

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

openjdk[bot] avatar May 26 '22 09:05 openjdk[bot]

Webrevs

mlbridge[bot] avatar May 26 '22 09:05 mlbridge[bot]

@tkiriyama You're using the wrong bugid. JDK-8272707 has nothing to do with URI. Please use the correct bugid.

aivanov-jdk avatar May 26 '22 12:05 aivanov-jdk

You're using the wrong bugid. JDK-8272707 has nothing to do with URI. Please use the correct bugid.

I'm sorry, I made a mistake. JDK-8272702 is correct. I fixed it.

tkiriyama avatar May 30 '22 06:05 tkiriyama

It seems like URI is currently behaving to spec. Even though the behavior is surprising, it's a corner case that isn't anticipated by the spec (or RFC 2396 for that matter). It looks like this was corrected in RFC 3986, but the whole resolution algorithm is specified differently in RFC 3986. I agree we would need to better understand the potential for incompatibility by making this change, eg how does it affect resolution + relativization round trips in these cases?

Michael-Mc-Mahon avatar Aug 09 '22 16:08 Michael-Mc-Mahon

I've thought about this some more and it does seem like the intent of RFC 2396 is clearly that an absolute URI should always have an absolute path (beginning with "/"). This implies when resolving a relative reference such as "test" against an absolute URI with an empty path, this implies a "/" needs to be added. RFC 3986 makes this explicit.

Existing code is probably working around the issue by adding a "/" explicitly when none present prior to resolution of the reference. I think we should go ahead with the change and I'm happy to sponsor it.

Michael-Mc-Mahon avatar Aug 11 '22 13:08 Michael-Mc-Mahon

@tkiriyama This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8272702: Resolving URI relative path with no / may lead to incorrect toString

Reviewed-by: dfuchs, michaelm

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 582 new commits pushed to the master branch:

  • 27b0f7726b70127c0ed714cfc1041d3da71a9dc3: 8292318: Memory corruption in remove_dumptime_info
  • 9a65524e2f98c1b4e253dcb637a708cec7b591bc: 8290300: Use standard String-joining tools where applicable
  • f9004fe4438c30eb639e3c36e6531c306b836e36: 8292561: Make "ReplayCompiles" a diagnostic product switch
  • 2fbb9362032df26582c389b7114cf0a215ed3afd: 8292691: Move CompilerConfig::is_xxx() inline functions out of compilerDefinitions.hpp
  • 3601e30df794db122d8d04fb3c04868ccbaa0baf: 8290909: MemoryPoolMBean/isUsageThresholdExceeded tests failed with "isUsageThresholdExceeded() returned false, and is still false, while threshold = MMMMMMM and used peak = NNNNNNN"
  • 37c0a13647e74fd02823a3f621e986f96904b933: 8292350: Use static methods for hashCode/toString primitives
  • 44532009fff11884aa6f16a997b771c41cb01d2f: 8292628: x86: Improve handling of constants in trigonometric stubs
  • 07c9ba74fa3baebffcc15d3ee6ef941edf6be1a3: 8292686: runtime/cds/appcds/TestWithProfiler.java SIGSEGV in TableStatistics ctr
  • 235151ead89f9102e3a57ba8f88807f180887866: 8292676: Remove two kerberos tests from problem list
  • df5209e70fd92ec6bda4e7356a3ad121732f6c66: 8292683: Remove BadKeyUsageTest.java from Problem List
  • ... and 572 more: https://git.openjdk.org/jdk/compare/649f2d8835027128c6c8cf37236808094a12a35f...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@dfuch, @Michael-Mc-Mahon) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

openjdk[bot] avatar Aug 11 '22 13:08 openjdk[bot]

@tkiriyama please /integrate and one of us will sponsor.

dfuch avatar Aug 15 '22 11:08 dfuch

/integrate

tkiriyama avatar Aug 22 '22 06:08 tkiriyama

I'm sorry for the late reply. I appreciate all reviews.

@dfuch Can I ask you to sponsor this fix?

tkiriyama avatar Aug 22 '22 06:08 tkiriyama

@tkiriyama Your change (at version d64e86b71f1f6fd45e04beae30cb0c8881604381) is now ready to be sponsored by a Committer.

openjdk[bot] avatar Aug 22 '22 06:08 openjdk[bot]

/sponsor

dfuch avatar Aug 22 '22 09:08 dfuch

Going to push as commit 79597f1ea6844f374beeeba219719cd9d5fe7d03. Since your change was applied there have been 585 commits pushed to the master branch:

  • 7b5f9edb59ef763acca80724ca37f3624d720d06: 8288966: Better handle very spiky promotion in G1
  • 07c797720d68d5a36d438f2e9da8b72f247f22fc: 8290249: Vectorize signum on AArch64
  • a3ec0bb03a5de805fc4b45477925aa18b875bc79: 8253413: [REDO] [REDO] G1 incorrectly limiting young gen size when using the reserve can result in repeated full gcs
  • 27b0f7726b70127c0ed714cfc1041d3da71a9dc3: 8292318: Memory corruption in remove_dumptime_info
  • 9a65524e2f98c1b4e253dcb637a708cec7b591bc: 8290300: Use standard String-joining tools where applicable
  • f9004fe4438c30eb639e3c36e6531c306b836e36: 8292561: Make "ReplayCompiles" a diagnostic product switch
  • 2fbb9362032df26582c389b7114cf0a215ed3afd: 8292691: Move CompilerConfig::is_xxx() inline functions out of compilerDefinitions.hpp
  • 3601e30df794db122d8d04fb3c04868ccbaa0baf: 8290909: MemoryPoolMBean/isUsageThresholdExceeded tests failed with "isUsageThresholdExceeded() returned false, and is still false, while threshold = MMMMMMM and used peak = NNNNNNN"
  • 37c0a13647e74fd02823a3f621e986f96904b933: 8292350: Use static methods for hashCode/toString primitives
  • 44532009fff11884aa6f16a997b771c41cb01d2f: 8292628: x86: Improve handling of constants in trigonometric stubs
  • ... and 575 more: https://git.openjdk.org/jdk/compare/649f2d8835027128c6c8cf37236808094a12a35f...master

Your commit was automatically rebased without conflicts.

openjdk[bot] avatar Aug 22 '22 09:08 openjdk[bot]

@dfuch @tkiriyama Pushed as commit 79597f1ea6844f374beeeba219719cd9d5fe7d03.

:bulb: You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

openjdk[bot] avatar Aug 22 '22 09:08 openjdk[bot]