Skip to content

Commit bc775d5

Browse files
committed
Bug 1486008 [wpt PR 10424] - XMLHttpRequest: response header value containing 0x00, a=testonly
Automatic update from web-platform-testsFetch/XHR: response header value containing 0x00 As discussed in whatwg/xhr#165 these should turn the response into a network error. -- wpt-commits: 3d172bc612e03a896b5611d9e9652f860995feef wpt-pr: 10424 UltraBlame original commit: 0d71b9cb47cea8e9ace98cbffa1585cd9c97c8ca
1 parent 500741d commit bc775d5

File tree

3 files changed

+40
-12
lines changed

3 files changed

+40
-12
lines changed

testing/web-platform/meta/MANIFEST.json

+23-1
Original file line numberDiff line numberDiff line change
@@ -351457,6 +351457,24 @@
351457351457
{}
351458351458
]
351459351459
],
351460+
"fetch/api/basic/header-value-null-byte.any.js": [
351461+
[
351462+
"/fetch/api/basic/header-value-null-byte.any.html",
351463+
{}
351464+
],
351465+
[
351466+
"/fetch/api/basic/header-value-null-byte.any.serviceworker.html",
351467+
{}
351468+
],
351469+
[
351470+
"/fetch/api/basic/header-value-null-byte.any.sharedworker.html",
351471+
{}
351472+
],
351473+
[
351474+
"/fetch/api/basic/header-value-null-byte.any.worker.html",
351475+
{}
351476+
]
351477+
],
351460351478
"fetch/api/basic/integrity.sub.any.js": [
351461351479
[
351462351480
"/fetch/api/basic/integrity.sub.any.html",
@@ -587916,6 +587934,10 @@
587916587934
"5701d6d7866b575dc162b27f70a336967c70911f",
587917587935
"testharness"
587918587936
],
587937+
"fetch/api/basic/header-value-null-byte.any.js": [
587938+
"9c223740c7807b43a6595ba81ef4f5b3c74c60b4",
587939+
"testharness"
587940+
],
587919587941
"fetch/api/basic/integrity.sub.any.js": [
587920587942
"d487c3738ac498f4b936e269c093ca2bad581cb0",
587921587943
"testharness"
@@ -658641,7 +658663,7 @@
658641658663
"testharness"
658642658664
],
658643658665
"xhr/headers-normalize-response.htm": [
658644-
"466b0d977cc6cdba12190a27dfe42e6452ea98d8",
658666+
"84f2fc8582127b9a8e271887d420b3ea7a87696a",
658645658667
"testharness"
658646658668
],
658647658669
"xhr/historical.html": [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
3+
promise_test(t => {
4+
return promise_rejects(t, new TypeError(), fetch("../../../xhr/resources/parse-headers.py?my-custom-header="+encodeURIComponent("x\0x")));
5+
}, "Ensure fetch() rejects null bytes in headers");

testing/web-platform/tests/xhr/headers-normalize-response.htm

+12-11
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
<title>Whitespace and null in header values</title>
44
<script src=/resources/testharness.js></script>
55
<script src=/resources/testharnessreport.js></script>
6-
<script src=support.js?pipe=sub></script>
7-
8-
<h1>Whitespace and null in response header values</h1>
9-
106
<div id=log></div>
11-
127
<script>
8+
function error(val) {
9+
test(() => {
10+
const client = new XMLHttpRequest();
11+
client.open("GET", "resources/parse-headers.py?my-custom-header="+encodeURIComponent(val), false);
12+
assert_throws("NetworkError", () => client.send());
13+
}, "Header value: " + val.replace("\0", "\\0"));
14+
}
1315

1416
function matchHeaderValue(val) {
1517
test(function () {
@@ -20,12 +22,12 @@ <h1>Whitespace and null in response header values</h1>
2022
var r = client.getResponseHeader("My-Custom-Header");
2123

2224
assert_equals(r, trimmed);
23-
}, "Header value: " + val.replace(/\t/g, "[tab]").replace(/ /g, "_").replace("\0", "\\0"));
25+
}, "Header value: " + val.replace(/\t/g, "[tab]").replace(/ /g, "_"));
2426
}
2527

26-
matchHeaderValue("hello world\0");
27-
matchHeaderValue("\0hello world");
28-
matchHeaderValue("hello\0world");
28+
error("hello world\0");
29+
error("\0hello world");
30+
error("hello\0world");
2931
matchHeaderValue(" hello world");
3032
matchHeaderValue("hello world ");
3133
matchHeaderValue(" hello world ");
@@ -34,9 +36,8 @@ <h1>Whitespace and null in response header values</h1>
3436
matchHeaderValue("\thello world\t");
3537
matchHeaderValue("hello world");
3638
matchHeaderValue("hello\tworld");
37-
matchHeaderValue("\0");
39+
error("\0");
3840
matchHeaderValue(" ");
3941
matchHeaderValue("\t");
4042
matchHeaderValue("");
41-
4243
</script>

0 commit comments

Comments
 (0)