Skip to content

fix(webapp): keep already encoded characters in proxied URLs - #2302

Merged
lbroudoux merged 1 commit into
microcks:masterfrom
PunKHS:fix-2291-proxy-url-double-encoding
Sep 15, 2026
Merged

lbroudoux merged 1 commit into
microcks:masterfrom
PunKHS:fix-2291-proxy-url-double-encoding

Conversation

@PunKHS

@PunKHS PunKHS commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #2291

With the PROXY or PROXY_FALLBACK dispatcher, a proxyUrl that already contains percent-encoded characters was
encoded a second time on the outbound request: %3A became %253A, %2F became %252F, and the query string had the same problem. Backends whose resource identifier must stay encoded inside a single path segment then resolve a
non-existent resource and return 404.

MockControllerCommons.getProxyUrlIfProxyIsNeeded() built the URI with UriComponentsBuilder.build(), which marks the components as not encoded, so toUri() uses the multi-args java.net.URI constructor that quotes % again.

Changes

  • MockControllerCommons.java: build with build(true) the proxyUrl, the incoming resource path and the query string are already URI encoded, so they are assembled as-is.

Fixes PROXY and PROXY_FALLBACK for the REST, SOAP and GraphQL invocation processors at once. Proxy URLs that are not valid URI syntax now hit the existing Invalid external URL in the dispatcher branch instead of being silently encoded.

Tests

  • MockControllerCommonsTest.ProxyUrlTests (7 tests): encoded PROXY url, resource path appending, encoded query
    string, encoded PROXY_FALLBACK url and the three no-proxy cases (response found, no proxy dispatcher, external url
    equal to the incoming one).
  • RestInvocationProcessorTest.shouldProxyRequestWithEncodedProxyUrl: asserts the URI handed to
    ProxyService.callExternal() keeps its raw path and raw query.
mvn -pl webapp -am -Dtest=MockControllerCommonsTest,RestInvocationProcessorTest -Dsurefire.failIfNoSpecifiedTests=false test

Prepared with the assistance of an AI coding agent. Reviewed, tested and owned by the human author.

@github-actions

Copy link
Copy Markdown

👋 @PunKHS

Welcome to the Microcks community! 💖

Thanks and congrats 🎉 for opening your first pull request here! Be sure to follow the pull request template or please update it accordingly.

Hope you have a great time there!

@SebastienDegodez SebastienDegodez added kind/bug java Pull requests that update Java code keep-open Explicitily keep open labels Sep 13, 2026
@SebastienDegodez SebastienDegodez added this to the 1.16.0 milestone Sep 13, 2026

@lbroudoux lbroudoux left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks great! Thanks for taking the time to push the fix!!
However, it seems that one integration test is now failing... I re-launched the CI build to check if this is not a flaky test but maybe it's a side effect...

@lbroudoux
lbroudoux merged commit f2be3d7 into microcks:master Sep 15, 2026
18 of 20 checks passed
@lbroudoux

Copy link
Copy Markdown
Member

No errors ... that was a flaky integration test. Ready to merge! Thanks!

@github-actions

Copy link
Copy Markdown

🎉 @PunKHS

You are now a Microcks community contributor! 💖

Thanks and congrats 🚀 on merging your first pull request! We are delighted and very proud of you! 👏

📢 If you're using Microcks in your organization, please add your company name to this list. 🙏 It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact.

If you need to know why and how to add yourself to the list, please read the blog post "Join the Microcks Adopters list and Empower the vibrant open source Community 🙌"

Kudos and please keep going, we need you 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/mocks java Pull requests that update Java code keep-open Explicitily keep open kind/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pre-encoded proxy URLs are double-encoded

3 participants