Repository navigation
Conversation
normalise_list split every header with the plain list grammar, so the fast path treated whitespace inside Link targets (<...>) and Via comments (...) as list separators. Values that differed only there compared as equal. Split with Grammar::for_header(name) instead, and add cases for Link, Via and Set-Cookie sent on separate lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lues A header with one value on each side and no matching rule was compared after splitting on every comma and trimming, so whitespace inside a Link <URI>, a Via comment or a quoted string was ignored (`<https://a/?x=1, 2>` matched `<https://a/?x=1,2>`). Use normalise_list, which only treats list-separating commas as insignificant, in the legacy matcher and in the V2 engine's multi-value header normalisation. The "quoted OWS fallback" case relied on that and now mismatches; the per-line deprecation warning test uses an unbalanced quote instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…scalar rule
A scalar rule on a repeated header reported only the joined mismatch
("Expected '1000, 1234, 9999ABC' to match '\d{1,4}'"), which doesn't say
which value failed. Report the per-line mismatches as well, and pass the
real list index to match_header_value in the matcher path instead of 0.
Fixes the V2 compatibility-suite scenario "Supports matchers for repeated
request headers (negative case)".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Follow-up to pact-foundation#584 (stacked on its branch
fix/repeated-headers-rfc9110).Problem
Header value normalisation ignored the header's grammar, so a comma inside a
Linktarget (<...>), aViacomment ((...)) or a quoted string was treated as a list separator. Values that differed only by whitespace there compared as equal. This happened in two places:normalise_listalways used the plain list grammar (the fast path inmatch_repeated_header).match_header_valuenormalised withsplit(',')+ trim. The V2 engine's multi-value normalisation did the same.Change
normalise_list(name, value)splits withGrammar::for_header(name), the same grammar used when matching each element.match_header_value's no-rule fallback and the V2 engine (engine/mod.rs,execute_normalize_comma_whitespace) usenormalise_listinstead of the naive split. Whitespace around list commas is still ignored (RFC 9110 §5.6.1).singleton separate lines: Set-Cookie on separate lines still matches.link whitespace inside target,via comment whitespace: no longer match (repeated values).single link whitespace inside target,single via comment whitespace,single quoted whitespace: no longer match (single values).single multi-value OWS:Cache-Control: no-cache,no-storevsno-cache, no-storestill matches.single multi-value quoted whitespace:Cache-Control: private="x,y"vsprivate="x, y"no longer matches.unbalanced quote fallback: an unbalanced quote runs to the end of the value.integeronREF-ID: 1111/REF-ID: two), the joined mismatch is now followed by a per-line mismatch for each failing value, e.g.Expected 'two' to match an integer number for value at index 1.match_header_lines, which reported every value as index 0. It now takes the index from the last path token.match_header_with_a_values_matcherand V2 engineheader_testsexpectations to match.Compatibility
No pact file format change. Matching is stricter in one way: whitespace inside a
<URI>, a(comment)or a quoted string is now significant.Cache-Control: private="x,y"used to matchprivate="x, y"and now doesn't. That's RFC 9110 correct, but worth a release note.The V2 engine still only normalises its known multi-value headers, so a custom single value
a,bvsa, bstill differs between the engines. That's unchanged here.Testing
cargo test -p pact_matching: all pass.Linkwith whitespace inside the URI now mismatches at V2/V3/V4. No other changes.🤖 Generated with Claude Code