Skip to content

Commit

Permalink
Bug 1500405 [wpt PR 13615] - MIME types: test 0x0B and 0x0C, a=testonly
Browse files Browse the repository at this point in the history
Automatic update from web-platform-testsMIME types: test 0x0B, 0x0C, and newlines

For whatwg/mimesniff#90.
--

wpt-commits: 6aeb68e38a61c2e332a7592f5cad640cf58b73f2
wpt-pr: 13615

UltraBlame original commit: 726abced3085ed5e9ef5b0df43e9561cac6f590d
  • Loading branch information
marco-c committed Oct 3, 2019
1 parent 319b822 commit 735c323
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 12 deletions.
5 changes: 1 addition & 4 deletions testing/web-platform/tests/mimesniff/mime-types/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@ A wrapper for these JSON MIME type tests needs to take care that not all `input`
function isByteCompatible(str) {
for(let i = 0; i < str.length; i++) {
const charCode = str.charCodeAt(i);
// See https://github.com/web-platform-tests/wpt/issues/8372 for 0x0B and 0x0C
// See https://fetch.spec.whatwg.org/#concept-header-value for the remainder
// See https://fetch.spec.whatwg.org/#concept-header-value
if(charCode > 0xFF) {
return "incompatible";
} else if(charCode === 0x00 || charCode === 0x0A || charCode === 0x0D) {
return "header-value-incompatible";
} else if(charCode === 0x0B || charCode === 0x0C) {
return "wptserve-incompatible";
}
}
return "compatible";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ function isByteCompatible(str) {
for(let i = 0; i < str.length; i++) {
const charCode = str.charCodeAt(i);


if(charCode > 0xFF) {
return "incompatible";
} else if(charCode === 0x00 || charCode === 0x0A || charCode === 0x0D) {
return "header-value-incompatible";
} else if(charCode === 0x0B || charCode === 0x0C) {
return "wptserve-incompatible";
}
}
return "compatible";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ function isByteCompatible(str) {
for(let i = 0; i < str.length; i++) {
const charCode = str.charCodeAt(i);


if(charCode > 0xFF) {
return "incompatible";
} else if(charCode === 0x00 || charCode === 0x0A || charCode === 0x0D) {
return "header-value-incompatible";
} else if(charCode === 0x0B || charCode === 0x0C) {
return "wptserve-incompatible";
}
}
return "compatible";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
def main(request, response):
response.headers.set("Content-Type", request.GET.first("type"));
response.content = "<meta charset=utf-8>\n<script>document.write(document.characterSet)</script>"
content = "<meta charset=utf-8>\n<script>document.write(document.characterSet)</script>"






response.add_required_headers = False
output = "HTTP/1.1 200 OK\r\n"
output += "Content-Length: " + str(len(content)) + "\r\n"
output += "Content-Type: " + request.GET.first("type") + "\r\n"
output += "\r\n"
output += content
response.writer.write(output)
response.close_connection = True
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,31 @@
"navigable": true,
"encoding": null
},
"0x0B and 0x0C",
{
"input": "text/html;charset=\u000Bgbk",
"output": "text/html",
"navigable": true,
"encoding": null
},
{
"input": "text/html;charset=\u000Cgbk",
"output": "text/html",
"navigable": true,
"encoding": null
},
{
"input": "text/html;\u000Bcharset=gbk",
"output": "text/html",
"navigable": true,
"encoding": null
},
{
"input": "text/html;\u000Ccharset=gbk",
"output": "text/html",
"navigable": true,
"encoding": null
},
"Single quotes are a token, not a delimiter",
{
"input": "text/html;charset='gbk'",
Expand Down Expand Up @@ -250,6 +275,18 @@
"input": "x/x;x=\t",
"output": "x/x"
},
{
"input": "x/x\n\r\t ;x=x",
"output": "x/x;x=x"
},
{
"input": "\n\r\t x/x;x=x\n\r\t ",
"output": "x/x;x=x"
},
{
"input": "x/x;\n\r\t x=x\n\r\t ;x=y",
"output": "x/x;x=x"
},
"Latin1",
{
"input": "text/html;test=\u00FF;charset=gbk",
Expand All @@ -263,6 +300,22 @@
"output": "x/x;x=x"
},
"Failure",
{
"input": "\u000Bx/x",
"output": null
},
{
"input": "\u000Cx/x",
"output": null
},
{
"input": "x/x\u000B",
"output": null
},
{
"input": "x/x\u000C",
"output": null
},
{
"input": "",
"output": null
Expand Down

0 comments on commit 735c323

Please sign in to comment.