fix: percent-encode reserved chars in actor/group gate URLs#54
Open
redac wants to merge 4 commits into
Open
Conversation
Templates.url_safe/1 used URI.encode/1 whose default predicate keeps reserved characters like / verbatim. Actor IDs and group names containing / (e.g. w:foo/bar) rendered form actions with a literal slash, which Plug.Router split into multiple segments and couldn't match — returning 404 on every toggle/clear action. Tighten url_safe/1 to URI.encode(&URI.char_unreserved?/1) and wrap the 4 redirect_to sites that interpolate actor_id/group_name with a new encode_segment/1 helper. Flag names are unaffected (already validated to ^\w+$ by Utils.validate_flag_name/2). Fixes tompave#53
Author
scr-2026-04-10-14.19.30.mp4 |
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.
Fixes #53.
Why
Actor IDs and group names are free-text input in the admin UI (
Utils.validate/1only rejects blank and?), so operators can legitimately create gates with values likew:foo/barortenants/eu. Once created, every toggle and clear action on these gates returns 404 because the literal/in the rendered URL gets split into extra path segments by the HTTP adapter, andPlug.Router's single-segment:actor_id/:group_nameparams can't match.What changed
Templates.url_safe/1to percent-encode all non-unreserved chars (including/)encode_segment/1inRouterto wrap the 4 redirect sites that interpolate gate values into Location headersNotes
^\w+$byUtils.validate_flag_name/2, so no encoding needed there/, so%2Fsurvives as a single segment