mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 10:07:15 +02:00
It's possible for the cookie value from a Set-Cookie header to contain invalid UTF-8. We must isomorphic decode this header. This fixes the /cookies/domain/domain-attribute-idn-host.sub.https.html WPT test. The test added here is a crash test rather than a text test because we cannot access the received Set-Cookie header from JS on the file:// test URL.
46 lines
1.4 KiB
HTML
46 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
|
<script src="../../Text/input/include.js"></script>
|
|
<script>
|
|
const TEST_SERVER_SET_INVALID_COOKIE = "X-Ladybird-Set-Invalid-Cookie";
|
|
|
|
const ACCESS_CONTROL_ALLOW_HEADERS = [TEST_SERVER_SET_INVALID_COOKIE].join(", ");
|
|
const ACCESS_CONTROL_EXPOSE_HEADERS = ["Set-Cookie"].join(", ");
|
|
|
|
const server = httpTestServer();
|
|
|
|
async function createRequest(path) {
|
|
await server.createEcho("OPTIONS", path, {
|
|
status: 200,
|
|
headers: {
|
|
"Access-Control-Allow-Credentials": "true",
|
|
"Access-Control-Allow-Headers": ACCESS_CONTROL_ALLOW_HEADERS,
|
|
"Access-Control-Allow-Methods": "GET",
|
|
"Access-Control-Allow-Origin": location.origin,
|
|
},
|
|
});
|
|
|
|
return server.createEcho("GET", path, {
|
|
status: 200,
|
|
headers: {
|
|
"Access-Control-Allow-Credentials": "true",
|
|
"Access-Control-Allow-Origin": location.origin,
|
|
"Access-Control-Expose-Headers": ACCESS_CONTROL_EXPOSE_HEADERS,
|
|
},
|
|
reflect_headers_in_body: true,
|
|
});
|
|
}
|
|
|
|
(async () => {
|
|
let url = await createRequest("/invalid-cookie");
|
|
|
|
await fetch(url, {
|
|
method: "GET",
|
|
credentials: "include",
|
|
mode: "cors",
|
|
headers: {
|
|
[TEST_SERVER_SET_INVALID_COOKIE]: "1",
|
|
}
|
|
});
|
|
})();
|
|
</script>
|