Repository navigation
Fix Unicode and escaped paths in JAR and directory loading - #225
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #225 +/- ##
==========================================
+ Coverage 87.29% 87.31% +0.02%
==========================================
Files 310 311 +1
Lines 46694 46772 +78
==========================================
+ Hits 40763 40841 +78
Misses 5931 5931 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🔵 Needs a closer look
It modifies the core class-loading/URL subsystem with subtle percent-encode/decode roundtrips that depend on third-party url-crate path normalization, which warrants final human verification despite the added tests.
No open issues 🎉
What changed in this PR
This PR fixes class and resource loading when classpath directories, JAR files, or JAR entry names contain Unicode characters or URL-significant characters (spaces, #, ?, %, literal +, and pre-escaped sequences like %20). The core idea is to make URL path handling symmetric: percent-encode filesystem paths and resource names when building file:/jar:file: URLs, and percent-decode them only when resolving to real files or JAR entries. A shared URL_PATH encode set and a decode_url_path helper (which raises IllegalArgumentException on invalid UTF-8) centralize this logic in java/net. This slots into the existing URL/URLStreamHandler/URLClassLoader subsystem that underpins classpath and executable-JAR loading.
Changes:
- Add
URL_PATHAsciiSet anddecode_url_pathhelper injava/net.rs, and apply encode-on-build / decode-on-access across the classpath and JAR loading paths. - Preserve literal
+and pre-escaped%sequences by encoding%and decoding only%XX(never treating+as space). - Extend runtime resource-loading tests for Unicode/escaped names and add CLI regression tests for classpath and
-jarloading, plus an invalid-UTF-8 error case.
| File | Description |
|---|---|
rustjava-runtime/src/classes/java/net.rs |
Adds URL_PATH encode set and decode_url_path helper with UTF-8 validation. |
rustjava-runtime/src/classes/java/lang/class_loader.rs |
Percent-encodes each classpath entry when building file: URLs. |
rustjava-runtime/src/classes/java/net/url_class_loader.rs |
Decodes URL file for filesystem lookups; re-encodes directory/jar-entry paths when emitting URLs. |
rustjava-runtime/src/classes/java/net/jar_url_connection.rs |
Decodes the JAR entry name (after !/) and validates UTF-8. |
rustjava-runtime/src/classes/org/rustjava/net/jar_url_connection.rs |
Decodes the JAR file URL path before opening the File. |
rustjava-runtime/src/classes/org/rustjava/net/file_url_handler.rs |
Decodes the file URL path before opening the File. |
rustjava-runtime/Cargo.toml, Cargo.lock |
Adds the percent-encoding dependency (no-std + alloc). |
rustjava-runtime/tests/classes/java/net/test_url_class_loader.rs |
Builds Unicode-named JAR/dir fixtures and asserts non-null resource resolution. |
rustjava-runtime/tests/classes/java/net/test_jar_url_connection.rs |
Verifies encoded JAR/entry parsing plus an invalid-UTF-8 IllegalArgumentException. |
tests/test_cli.rs |
Adds CLI regression coverage for Unicode/escaped classpath and -jar loading. |
Review effort: Balanced
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9edee23335
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Changes
org.rustjava.net.URLPathutility class with static encoding/decoding methods, shared by class loaders and URL connections.Verification
Wasm execution was not tested.