Skip to content

fix(proxy): preserve percent-encoded reserved chars in upstream path#156

Merged
mslipper merged 1 commit into
mainfrom
fix/preserve-escaped-slashes
May 27, 2026
Merged

fix(proxy): preserve percent-encoded reserved chars in upstream path#156
mslipper merged 1 commit into
mainfrom
fix/preserve-escaped-slashes

Conversation

@mslipper

Copy link
Copy Markdown
Contributor

The HTTP handler built the upstream URL from r.URL.Path (already decoded), so %2F and other percent-encoded reserved characters were collapsed before the upstream request was constructed. This broke APIs like GCS that route on encoded slashes within a single path segment (e.g. /o/<object> where the object name contains slashes). The fix constructs the upstream URL via url.URL with both Path and RawPath set so EscapedPath preserves the original encoding end-to-end.

Audited existing transforms: oauth/gcpauth/awsauth/hmacsign only read URL.Path; token_broker_resolver builds its own URL with RawPath set; secrets swapPath clears RawPath after substitution, which is fine for placeholder tokens but would re-encode a coexisting %2F in the same path (narrow edge case, predates this fix).

Fixes #155.

The HTTP handler built the upstream URL from r.URL.Path (already
decoded), so %2F and other percent-encoded reserved characters were
collapsed before the upstream request was constructed. This broke APIs
like GCS that route on encoded slashes within a single path segment
(e.g. /o/<object> where the object name contains slashes).

Construct the upstream URL via url.URL with both Path and RawPath set
so EscapedPath preserves the original encoding through the upstream
RoundTrip.

Fixes #155.
@mslipper mslipper merged commit 8f1d8ef into main May 27, 2026
6 of 7 checks passed
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.

URL path %2F-decoding mangles GCS object names containing slashes

1 participant