fix: encode URL client-side to prevent double-slash normalization - #144
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: encode target URL client-side to prevent double-slash normalization
Closes #75
Problem
When a user submits a URL through the web UI, the form navigates to
/<target_url>as a raw path. Browsers and reverse proxies (nginx, Traefik, Apache) normalize//in paths per RFC 3986, collapsinghttps://tohttps:/. By the time the request reaches Ladder, the hostname is gone and it errors withhttp: no Host in request URL.The existing workarounds (nginx
merge_slashes off, TraefiksanitizePath: false, pinning Traefik to v3.3.5) are fragile and proxy-specific.Fix
Encode the target URL with
encodeURIComponentin the submit handler before navigation, so the browser never sees a raw://in the path.decodeURIComponentis applied first to avoid double-encoding URLs that are already partially encoded (e.g. containing%20). A try/catch handles the edge case of malformed percent sequences.This fix is proxy-agnostic and requires no configuration changes on the server side.