Skip to content

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

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

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
@jhoeller

jhoeller commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

This is being worken on separately, under the original #37280, aiming to resolve the issue in a more defensive fashion.

In general, we recommend to wait a bit before implementing a solution - until a core maintainer triaged the issue. In particular for core framework issues, it is rather unlikely that a PR for an untriaged issue will be accepted as-is.

@jhoeller jhoeller closed this Sep 18, 2026
@jhoeller jhoeller added status: superseded An issue that has been superseded by another and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: superseded An issue that has been superseded by another

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants