Skip to content

Commit

Permalink
Bug 1486008 [wpt PR 10424] - XMLHttpRequest: response header value co…
Browse files Browse the repository at this point in the history
…ntaining 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
  • Loading branch information
annevk authored and moz-wptsync-bot committed Aug 31, 2018
1 parent f37395a commit 5e6eac9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
24 changes: 23 additions & 1 deletion testing/web-platform/meta/MANIFEST.json
Original file line number Diff line number Diff line change
Expand Up @@ -351457,6 +351457,24 @@
{}
]
],
"fetch/api/basic/header-value-null-byte.any.js": [
[
"/fetch/api/basic/header-value-null-byte.any.html",
{}
],
[
"/fetch/api/basic/header-value-null-byte.any.serviceworker.html",
{}
],
[
"/fetch/api/basic/header-value-null-byte.any.sharedworker.html",
{}
],
[
"/fetch/api/basic/header-value-null-byte.any.worker.html",
{}
]
],
"fetch/api/basic/integrity.sub.any.js": [
[
"/fetch/api/basic/integrity.sub.any.html",
Expand Down Expand Up @@ -587916,6 +587934,10 @@
"5701d6d7866b575dc162b27f70a336967c70911f",
"testharness"
],
"fetch/api/basic/header-value-null-byte.any.js": [
"9c223740c7807b43a6595ba81ef4f5b3c74c60b4",
"testharness"
],
"fetch/api/basic/integrity.sub.any.js": [
"d487c3738ac498f4b936e269c093ca2bad581cb0",
"testharness"
Expand Down Expand Up @@ -658641,7 +658663,7 @@
"testharness"
],
"xhr/headers-normalize-response.htm": [
"466b0d977cc6cdba12190a27dfe42e6452ea98d8",
"84f2fc8582127b9a8e271887d420b3ea7a87696a",
"testharness"
],
"xhr/historical.html": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// META: global=window,worker

promise_test(t => {
return promise_rejects(t, new TypeError(), fetch("../../../xhr/resources/parse-headers.py?my-custom-header="+encodeURIComponent("x\0x")));
}, "Ensure fetch() rejects null bytes in headers");
23 changes: 12 additions & 11 deletions testing/web-platform/tests/xhr/headers-normalize-response.htm
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
<title>Whitespace and null in header values</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=support.js?pipe=sub></script>

<h1>Whitespace and null in response header values</h1>

<div id=log></div>

<script>
function error(val) {
test(() => {
const client = new XMLHttpRequest();
client.open("GET", "resources/parse-headers.py?my-custom-header="+encodeURIComponent(val), false);
assert_throws("NetworkError", () => client.send());
}, "Header value: " + val.replace("\0", "\\0"));
}

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

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

matchHeaderValue("hello world\0");
matchHeaderValue("\0hello world");
matchHeaderValue("hello\0world");
error("hello world\0");
error("\0hello world");
error("hello\0world");
matchHeaderValue(" hello world");
matchHeaderValue("hello world ");
matchHeaderValue(" hello world ");
Expand All @@ -34,9 +36,8 @@ <h1>Whitespace and null in response header values</h1>
matchHeaderValue("\thello world\t");
matchHeaderValue("hello world");
matchHeaderValue("hello\tworld");
matchHeaderValue("\0");
error("\0");
matchHeaderValue(" ");
matchHeaderValue("\t");
matchHeaderValue("");

</script>

0 comments on commit 5e6eac9

Please sign in to comment.