Skip to content

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

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

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

Conversation

@wyf027

@wyf027 wyf027 commented May 25, 2026

Copy link
Copy Markdown

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 #781

Co-authored-by: Cursor <cursoragent@cursor.com>
@wyf027 wyf027 closed this by deleting the head repository Jun 23, 2026
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