Skip to content

Encode file paths when creating resource URLs - #865

Merged
peter-lawrey merged 2 commits into
developfrom
fix/file-url-encoding
Sep 14, 2026
Merged

peter-lawrey merged 2 commits into
developfrom
fix/file-url-encoding

Conversation

@peter-lawrey

@peter-lawrey peter-lawrey commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

Refresh on 12 September 2026

Merged develop 9c26a484f3150c7f079aea626abffac22e53a506 into the existing branch without rewriting history. Updated head: 65a3751bcb73bb88b8336f9106ad1bdd7f207a91. Both the declared base and develop are ancestors of this head.

Fresh Linux/OpenJDK 21 full Maven verify passed: 1882 reported tests, no failures or errors.

Platform CI and repository merge gates remain separate. Earlier implementation and validation details follow; their recorded results apply to the revisions stated there.


Why and scope

Each branch starts directly from current develop ebcf76e91cb7a57b3626c1de7e0a67fc42a514a8. This is an independent behavioural extraction from #846, not a JUnit migration or annotation/checker rewrite.

Constructing a file URL from an unescaped pathname treats a literal # as a fragment and can misinterpret percent signs, so the returned URL does not reliably open the requested file.

Use toAbsolutePath().toUri().toURL() for the existing filesystem fallback. Keep resource lookup, compressed-resource fallback and missing-file behaviour unchanged. Do not introduce the separate toRealPath policy from #846; a symlink URL retains its supplied path.

Verification performed

Actual Chronicle-Core Maven builds on Linux x64, using Maven 3.9.11 and mvn -B -nsu clean verify -Dsurefire.rerunFailingTestsCount=0 -l <log>:

JVM Tests Failures/errors Skipped
OpenJDK 8u502 1878 0 / 0 5
OpenJDK 21.0.12 1878 0 / 0 0

The five Java 8 skips are existing JDK-specific tests; none of the added cases skipped. Full verify includes licence and binary-compatibility checks. Test retries were disabled.

All eight focused cases pass: actual reads of filenames with #, spaces, percent signs and plus signs, a plain filename, link-path preservation, resource lookup/fallback and missing files. TempDir and try-with-resources provide failure-path cleanup.

Three cases fail/error against develop. Against #846's exact head (73ab2a6), the symlink-path test fails because toRealPath substitutes the target. All pass with this one-line behavioural fix.

The unchanged POM resolves Chronicle Test Framework 2026.2, JUnit Jupiter 5.10.0, Affinity 2026.2 and POSIX 2026.2. No dependency bump is included. Platform CI remains a separate gate; Windows, Mac and ARM hardware were not run locally. Java 26+ results are informational under the project review policy.

Boundaries

Only URL encoding changes in release code, with an adjacent //! reason. No canonicalisation/security-policy claim, public API or POM/version changes, annotations or unrelated I/O cleanup.

Encode filesystem paths through URI before constructing a resource URL.
The old unescaped form treats filename characters as URL syntax.

All eight focused cases and full Java 8/21 verify pass. The tests reject
both develop's broken filename handling and #846's extra symlink
canonicalisation policy. Preserve classpath lookup and fallback behaviour.

Extract the URL encoding fix from #846 without real-path resolution.
The topic branch lacks commits from its current base.

Merge the fetched base without rewriting history and retain the
PR-specific behaviour alongside upstream fixes.
@peter-lawrey
peter-lawrey merged commit f782ddd into develop Sep 14, 2026
9 of 12 checks passed
@peter-lawrey
peter-lawrey deleted the fix/file-url-encoding branch September 14, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants