You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I.e.: a header value with a comma as the last character is split into two values, as in the example. Since the header is Content-Length and the spec mandates to abort if the split values don't match, the test passes if the request results in a network error.
What is the issue with the Fetch Standard?
https://fetch.spec.whatwg.org/commit-snapshots/4cb3cf21946113c0684f04122dd95315fd10c567/#header-value-get-decode-and-split
The algorithm doesn't seem to return the same output of the first example.
The example says that giving
nosniff,
as input we should get a list of two strings:"nosniff"
and an empty string""
.If I try to follow the steps however I get a list of a single
"nosniff"
string and no empty string.Here's how I'm interpreting it:
Here position is past the end of input, the while condition is not satisfied and this returns a list with just a single element:
["nosniff"]
.The examples seem right to me, I think the algorithm is wrong.
I found some WPT that indirectly test this algorithm (via
Content-Length
), Chrome and Firefox seem to follow the behavior of the example.https://github.com/web-platform-tests/wpt/blob/merge_pr_47660/fetch/content-length/resources/content-lengths.json#L66-L69
https://wpt.fyi/results/fetch/content-length/parsing.window.html
I.e.: a header value with a comma as the last character is split into two values, as in the example. Since the header is
Content-Length
and the spec mandates to abort if the split values don't match, the test passes if the request results in a network error.This should be the relevant Chrome implementation, it looks like it internally stores every header splitted
https://source.chromium.org/chromium/chromium/src/+/main:net/http/http_response_headers.cc;l=967-970;drc=82dff63dbf9db05e9274e11d9128af7b9f51ceaa;bpv=0;bpt=1
https://source.chromium.org/chromium/chromium/src/+/main:net/http/http_util.cc;l=968;drc=82dff63dbf9db05e9274e11d9128af7b9f51ceaa
Firefox on the other hand doesn't seem to do that, the
Content-Length
check appears to be implemented using a simpler split by just commas, ignoring quotes. It makes sense: a quote char insideContent-Length
already makes it invalid so there's no need to care about quotes while splitting.https://searchfox.org/mozilla-central/rev/53e68046298557fae0c922230b595bb6689bf587/netwerk/protocol/http/nsHttpHeaderArray.cpp#173-189
https://searchfox.org/mozilla-central/rev/53e68046298557fae0c922230b595bb6689bf587/netwerk/protocol/http/nsHttpHeaderArray.h#308
The text was updated successfully, but these errors were encountered: