fix(network): do not split single-valued and http-date headers on comma - #42723
Mohan Ram (mohanram-dev) wants to merge 1 commit into
Conversation
|
Reporter of #42687 here. Ran the reproducer from the issue against this branch on all three engines, and it fixes every case I filed.
I also checked the thing I was worried about when I filed it, since the split existed to recover headers the protocol had already joined. No regression there: One residual difference, which I do not think is yours to fix but is worth knowing the boundary of. A single genuinely list-valued header still splits on the two non-Chromium engines: That is the ambiguity I mentioned on the issue rather than a new problem: once the protocol has joined repeated headers into one string, nothing downstream can tell one comma-list header from two repeated ones, so some guess is unavoidable. Your allowlist removes the cases where the guess is provably wrong, which is the part that was actually corrupting data. Just flagging it so a reviewer is not surprised that chromium and the others still differ on that one shape. Nice work on this, the RFC 9110 framing is a much better justification than the "exclude the date headers" hand-wave I had in the issue. |
|
Thanks Ayaan Gazali (@ayaangazali) for testing and verifying across all three engines! Seeing that Devin Rousso (@dcrousso) opened #42734 with the minimal splitHeaderValue approach (already approved and passed CI), I will close this PR once #42734 is merged into main. |
Description
Fixes #42687.
On Firefox and WebKit, response headers are provided joined or parsed through internal comma splitting (
ffNetworkManager.tsandheadersObjectToArray).Per RFC 9110 §5.3, field lines containing an HTTP-date (
Date,Expires,Last-Modified,If-Modified-Since,If-Unmodified-Since,Retry-After) and standard single-valued headers (Location,Content-Type,Content-Disposition, etc.) are not comma-separated lists. Splitting on,corrupted every date header (e.g., splitting"Wed, 21 Oct 2026 07:28:00 GMT"into"Wed"and"21 Oct 2026 07:28:00 GMT"). Additionally, on macOS WebKit wherewkSetCookieSeparator = ',', cookies withExpiresattributes containing commas were being split within the date string.This PR:
singleValuedHeadersSet inpackages/isomorphic/headers.tscontaining standard single-valued and HTTP-date header names.headersObjectToArrayto preserve single-valued headers intact without splitting on,.splitSetCookieStringto safely handle comma-separated Set-Cookie headers while preserving dates insideExpires=...attributes.ffNetworkManager.ts(parseMultivalueHeaders) to avoid splitting single-valued and date headers on commas.tests/library/unit/headers.spec.ts) and end-to-end response header tests (tests/page/page-network-response.spec.ts).