Skip to content

Commit c1b160a

Browse files
committed
Bug 1606798 [wpt PR 21019] - HTTP: 0x00 in a header value, a=testonly
Automatic update from web-platform-tests HTTP: 0x00 in a header value Tests to complement those written in web-platform-tests/wpt#10424. -- wpt-commits: 38ecde806a5f1710d9e5beba700cef7352f7570e wpt-pr: 21019 UltraBlame original commit: 2df4f38122005c353cf34c665c293fcb975fbdb7
1 parent 40bfed1 commit c1b160a

6 files changed

+46
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
async_test(t => {
2+
const script = document.createElement("script");
3+
t.add_cleanup(() => script.remove());
4+
script.src = "resources/script-with-0x00-in-header.py";
5+
script.onerror = t.step_func_done();
6+
script.onload = t.unreached_func();
7+
document.body.append(script);
8+
}, "Expect network error for script with 0x00 in a header");
9+
10+
async_test(t => {
11+
const frame = document.createElement("iframe");
12+
t.add_cleanup(() => frame.remove());
13+
frame.src = "resources/document-with-0x00-in-header.py";
14+
15+
16+
17+
t.step_timeout(() => {
18+
assert_equals(frame.contentDocument, null);
19+
t.done();
20+
}, 1000);
21+
document.body.append(frame);
22+
}, "Expect network error for frame navigation to resource with 0x00 in a header");
23+
24+
async_test(t => {
25+
const img = document.createElement("img");
26+
t.add_cleanup(() => img.remove());
27+
img.src = "resources/blue-with-0x00-in-a-header.asis";
28+
img.onerror = t.step_func_done();
29+
img.onload = t.unreached_func();
30+
document.body.append(img);
31+
}, "Expect network error for image with 0x00 in a header");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
`blue-with-0x00-in-a-header.asis` is a copy from `../../images/blue.png` with the following prepended using Control Pictures to signify actual newlines and 0x00:
2+
```
3+
HTTP/1.1 200 AN IMAGE␍␊
4+
Content-Type: image/png␍␊
5+
Custom: ␀␍␊␍␊
6+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
def main(request, response):
2+
response.headers.set("Content-Type", "text/html")
3+
response.headers.set("Custom", "\0")
4+
return "<!doctype html><b>This is a document.</b>"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
def main(request, response):
2+
response.headers.set("Content-Type", "text/javascript")
3+
response.headers.set("Custom", "\0")
4+
return "var thisIsJavaScript = 0"

testing/web-platform/tests/lint.whitelist

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ AHEM COPY: css/vendor-imports/mozilla/mozilla-central-reftests/*/Ahem.ttf
7777
# Intentional use of CRLF
7878
CR AT EOL: WebIDL/valid/idl/documentation-dos.widl
7979
CR AT EOL: cors/resources/cors-headers.asis
80+
CR AT EOL: fetch/h1-parsing/resources/blue-with-0x00-in-a-header.asis
8081
CR AT EOL: html/semantics/forms/the-textarea-element/multiline-placeholder-cr.html
8182
CR AT EOL: html/semantics/forms/the-textarea-element/multiline-placeholder-crlf.html
8283
CR AT EOL: html/semantics/forms/the-input-element/multiline-placeholder-cr.html

0 commit comments

Comments
 (0)