Skip to content

#1413: Handle "+" character in file paths#1414

Open
baxter-huntington wants to merge 1 commit into
jpype-project:masterfrom
baxter-huntington:uri-encoded-plus-fix
Open

#1413: Handle "+" character in file paths#1414
baxter-huntington wants to merge 1 commit into
jpype-project:masterfrom
baxter-huntington:uri-encoded-plus-fix

Conversation

@baxter-huntington

@baxter-huntington baxter-huntington commented Jul 1, 2026

Copy link
Copy Markdown

URLDecoder.decode applies the application/x-www-form-urlencoded MIME format, which includes converting "+" characters to space characters. If a path contains "+" characters, upon re-encoding, they will be converted to %20 instead of %2b, yielding a different file path than we started with.

We handle this by converting "+" to "%2b" before decoding to ensure that it is preserved across the round trip.

Resolves: #1413

URLDecoder.decode applies the application/x-www-form-urlencoded MIME
format, which includes converting "+" characters to space characters.
If a path contains "+" characters, upon re-encoding, they will be
converted to %20 instead of %2b, yielding a different file path than we
started with.

We handle this by converting "+" to "%2b" before decoding to ensure that
it is preserved across the round trip.
@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.17%. Comparing base (a1a50c0) to head (ca1aff0).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1414      +/-   ##
==========================================
- Coverage   86.24%   86.17%   -0.07%     
==========================================
  Files         112      112              
  Lines       10289    10289              
  Branches     4056     4056              
==========================================
- Hits         8874     8867       -7     
- Misses        809      814       +5     
- Partials      606      608       +2     

see 4 files with indirect coverage changes

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

@Thrameos

Thrameos commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Seems very reasonable, though we will likely need to improve it a bit before inclusion.

  1. Is '+' the only problem character or do we need more substitutions?

AI states this is likely needed.

/ Centralized protection for characters that have special meaning in 
// x-www-form-urlencoded but are literal characters in file paths.
private static String prepareForDecoding(String input) {
    return input.replace("+", "%2b")
                .replace("&", "%26")
                .replace("=", "%3D")
                .replace("#", "%23");
}
  1. We need a doc/CHANGELOG entry so we track the improvement
  2. We need something in test/jpypetest that exercises the bug.

I can generate those for you when I have development cycles free. Or you can add it and we can skip straight to review.

Thanks for the contribution!

@baxter-huntington

Copy link
Copy Markdown
Author

@Thrameos I appreciate the quick look and response 😃 I'd be happy to address those items. I should have some time to get to them tomorrow.

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.

Literal "+" characters in file paths are incorrectly converted to spaces

2 participants