Skip to content

fix(router): keep escaped colon and parameter routes reachable - #3113

Open
wofiporia wants to merge 1 commit into
labstack:masterfrom
wofiporia:fix-escaped-colon-param-route
Open

wofiporia wants to merge 1 commit into
labstack:masterfrom
wofiporia:fix-escaped-colon-param-route

Conversation

@wofiporia

Copy link
Copy Markdown

Fixes #3111

A route with a literal colon (written as \:) and a parameter route at the same tree position used the same : marker during insertion, so a parameter node could end up attached as a static child of its parent. Backtracking then treated it as a parameter that was never entered, panicking with index out of range [-1]; the reverse registration order left the escaped colon route unreachable.

Insert parameters with an internal placeholder that can not collide with a literal :.

Added TestRouterParam_escapeColonAndParamConflict covering both registration orders.

A route with a literal colon (written as `\:`) and a parameter route at the
same tree position used the same `:` marker during insertion, so a parameter
node could end up attached as a static child of its parent. Backtracking then
treated it as a parameter that was never entered, panicking with
`index out of range [-1]`; the reverse registration order left the escaped
colon route unreachable.

Insert parameters with an internal placeholder that can not collide with a
literal `:`.
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.

A \: route and a :param route at the same position make ServeHTTP panic or return 404

1 participant