fix: trim OWS after commas when splitting list parameters - #1089
Open
stareezy-1 wants to merge 1 commit into
Open
fix: trim OWS after commas when splitting list parameters#1089stareezy-1 wants to merge 1 commit into
stareezy-1 wants to merge 1 commit into
Conversation
RFC 9110 $5.6.1 list grammar permits optional whitespace around each comma, e.g. 'If-None-Match: "a", "b"'. The list-splitting code in parseInto kept the leading space on every element after the first, so conditional.Params ETag comparisons silently missed legitimate matches and served a 200 instead of a 304.
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.
Summary
Fixes #1084
Problem
parseIntosplits list-style header/query params on a literal comma:RFC 9110 §5.6.1 list grammar permits optional whitespace (OWS) around each comma, so a conventional
If-None-Match: "a", "b"produces["\"a\"", " \"b\""]— every element after the first keeps a leading space.conditional.trimETagstrips quotes but not whitespace, so the space-tainted element can never equal a bare ETag: a 304-eligible request silently returns a full 200.Reproduction:
Fix
Trim OWS (
" \t") from each element at the shared split site inparseInto. This fixes every list-style header/query param at once rather than just theconditionalpackage, matching the fix location suggested in the issue.Tests
TestIfNoneMatchOWSAfterCommainconditional/params_test.goregisters a real operation with embeddedParamsand asserts:"other-tag", "target-tag"(OWS on second element)"target-tag", "other-tag"(OWS elsewhere)"other-tag","target-tag"(no space)All existing tests continue to pass (
go test -race ./...).