Skip to content

Encode percent signs in Class-Path jar URLs - #37281

Open
kalayciburak wants to merge 1 commit into
spring-projects:mainfrom
kalayciburak:gh-37280-encode-percent-in-classpath-jar-urls
Open

kalayciburak wants to merge 1 commit into
spring-projects:mainfrom
kalayciburak:gh-37280-encode-percent-in-classpath-jar-urls

Conversation

@kalayciburak

Copy link
Copy Markdown

Motivation

ClassPathManifestEntry.fixPath already encodes # so java.net.URL does not treat it as a fragment (gh-26104). It does not encode %, so a jar on java.class.path whose directory name contains % is either skipped (host%3A8099 is decoded to host:8099) or causes IllegalArgumentException: 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 %25 before encoding # in fixPath, matching the JDK ClassLoader.getResource URL form.

Tests

  • PathMatchingResourcePatternResolverTests$ClassPathManifestEntries.javaDashJarFindsClassPathManifestEntriesWhenPathContainsPercentHex
  • PathMatchingResourcePatternResolverTests$ClassPathManifestEntries.javaDashJarFindsClassPathManifestEntriesWhenPathContainsLonePercent
  • full PathMatchingResourcePatternResolverTests
  • :spring-core:checkstyleMain and :spring-core:checkstyleTest

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>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PathMatchingResourcePatternResolver misses jars on java.class.path whose path contains %

2 participants