Skip to content

feat: add StrictQueryParamSep for net/url-aligned query matching#801

Open
leno23 wants to merge 1 commit into
gorilla:mainfrom
leno23:fix/strict-query-param-sep
Open

feat: add StrictQueryParamSep for net/url-aligned query matching#801
leno23 wants to merge 1 commit into
gorilla:mainfrom
leno23:fix/strict-query-param-sep

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 25, 2026

Summary

  • Adds opt-in Router.StrictQueryParamSep(true) for Queries route matching
  • When enabled, query parameter pairs are split on & only, aligning with net/url since Go 1.17
  • Default remains false to preserve legacy splitting on both & and ;

Fixes #781

Problem

Queries matching treats ; as a parameter separator while modern net/url does not. Mixed use (e.g. auth checks via r.URL.Query() and routing via mux.Vars) can disagree on parameter values, enabling authorization bypasses.

Approach

This follows option 2 from the issue discussion: an opt-in router flag with backward-compatible defaults, avoiding an immediate breaking change for clients that rely on semicolon-separated query strings.

Test plan

  • go test -run 'Test_findFirstQueryKey|TestStrictQueryParamSep' -v
  • go test ./... -count=1

Introduce Router.StrictQueryParamSep to optionally split Queries route
parameters on '&' only, matching net/url since Go 1.17. The default
false preserves legacy ';' splitting for backward compatibility.

Fixes gorilla#781

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Semicolon unduly acts as separator for query parameters (thereby creating a parser differential)

1 participant