Skip to content

Fix Unicode and escaped paths in JAR and directory loading - #225

Merged
dlunch merged 2 commits into
mainfrom
fix/unicode-jar-paths
Oct 23, 2026
Merged

dlunch merged 2 commits into
mainfrom
fix/unicode-jar-paths

Conversation

@dlunch

@dlunch dlunch commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Changes

  • Add the internal org.rustjava.net.URLPath utility class with static encoding/decoding methods, shared by class loaders and URL connections.
  • Fix Unicode and escaped JAR/directory loading by encoding paths at URL construction and decoding at file or JAR-entry lookup, preserving literal plus signs and percent sequences.
  • Extend resource-loading coverage and add CLI regression coverage for classpath and executable JAR loading.

Verification

  • Workspace tests: 557 passed, 2 ignored.
  • Native all-targets and wasm32-unknown-unknown Clippy checks passed with warnings denied.
  • Formatting and diff checks passed.

Wasm execution was not tested.

Copilot AI balanced review requested due to automatic review settings October 23, 2026 11:46
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T11:56:27.143038Z 9edee23 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.31%. Comparing base (f9eb19a) to head (9edee23).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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_PATH AsciiSet and decode_url_path helper in java/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 -jar loading, 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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread rustjava-runtime/src/classes/org/rustjava/net/url_path.rs
@dlunch
dlunch merged commit d960d1b into main Oct 23, 2026
13 checks passed
@dlunch
dlunch deleted the fix/unicode-jar-paths branch October 23, 2026 11:56
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