Encode percent signs in Class-Path jar URLs - #37281
Open
kalayciburak wants to merge 1 commit into
Open
kalayciburak wants to merge 1 commit into
kalayciburak wants to merge 1 commit into
Conversation
ClassPathManifestEntry.fixPath already encodes '#' so that java.net.URL does not treat it as a fragment. The same is needed for '%' which otherwise becomes an escape sequence when the jar:file: URL is opened. Jars on java.class.path whose directory names contain '%' (for example Coursier's host%3A8099 cache) were therefore skipped or caused IllegalArgumentException. Closes spring-projectsgh-37280 Signed-off-by: Burak KALAYCI <kalayciburak1996@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
ClassPathManifestEntry.fixPathalready encodes#sojava.net.URLdoes not treat it as a fragment (gh-26104). It does not encode%, so a jar onjava.class.pathwhose directory name contains%is either skipped (host%3A8099is decoded tohost:8099) or causesIllegalArgumentException: Malformed escape pair(100%).That path shape appears in practice with Coursier caches (
~/Library/Caches/Coursier/v1/http/localhost%3A8099/...).Closes gh-37280
Change
Encode
%to%25before encoding#infixPath, matching the JDKClassLoader.getResourceURL form.Tests
PathMatchingResourcePatternResolverTests$ClassPathManifestEntries.javaDashJarFindsClassPathManifestEntriesWhenPathContainsPercentHexPathMatchingResourcePatternResolverTests$ClassPathManifestEntries.javaDashJarFindsClassPathManifestEntriesWhenPathContainsLonePercentPathMatchingResourcePatternResolverTests:spring-core:checkstyleMainand:spring-core:checkstyleTest