mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb: Do not move header name/values that are re-used
Fixes a regression from commit:
f675cfe90f
This commit is contained in:
parent
cbfae97101
commit
7b0dfa61b1
Notes:
github-actions[bot]
2025-11-27 02:23:40 +00:00
Author: https://github.com/trflynn89
Commit: 7b0dfa61b1
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6949
5 changed files with 121 additions and 2 deletions
|
|
@ -247,7 +247,7 @@ WebIDL::ExceptionOr<void> Headers::append(Infrastructure::Header header)
|
|||
|
||||
// 2. If temporaryValue is null, then set temporaryValue to value.
|
||||
if (!temporary_value.has_value()) {
|
||||
temporary_value = move(value);
|
||||
temporary_value = value;
|
||||
}
|
||||
// 3. Otherwise, set temporaryValue to temporaryValue, followed by 0x2C 0x20, followed by value.
|
||||
else {
|
||||
|
|
@ -255,7 +255,7 @@ WebIDL::ExceptionOr<void> Headers::append(Infrastructure::Header header)
|
|||
}
|
||||
|
||||
auto temporary_header = Infrastructure::Header {
|
||||
.name = move(name),
|
||||
.name = name,
|
||||
.value = temporary_value.release_value(),
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
Harness status: OK
|
||||
|
||||
Found 27 tests
|
||||
|
||||
27 Pass
|
||||
Pass Loading data…
|
||||
Pass "no-cors" Headers object cannot have accept set to sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss, , sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
|
||||
Pass "no-cors" Headers object cannot have accept-language set to sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss, , sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
|
||||
Pass "no-cors" Headers object cannot have content-language set to sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss, , sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
|
||||
Pass "no-cors" Headers object cannot have accept set to , sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
|
||||
Pass "no-cors" Headers object cannot have accept-language set to , sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
|
||||
Pass "no-cors" Headers object cannot have content-language set to , sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
|
||||
Pass "no-cors" Headers object cannot have content-type set to text/plain;ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss, text/plain
|
||||
Pass "no-cors" Headers object cannot have accept/" as header
|
||||
Pass "no-cors" Headers object cannot have accept/012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678 as header
|
||||
Pass "no-cors" Headers object cannot have accept-language/ as header
|
||||
Pass "no-cors" Headers object cannot have accept-language/@ as header
|
||||
Pass "no-cors" Headers object cannot have authorization/basics as header
|
||||
Pass "no-cors" Headers object cannot have content-language/ as header
|
||||
Pass "no-cors" Headers object cannot have content-language/@ as header
|
||||
Pass "no-cors" Headers object cannot have content-type/text/html as header
|
||||
Pass "no-cors" Headers object cannot have content-type/text/plain; long=0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901 as header
|
||||
Pass "no-cors" Headers object cannot have range/bytes 0- as header
|
||||
Pass "no-cors" Headers object cannot have test/hi as header
|
||||
Pass "no-cors" Headers object cannot have dpr/2 as header
|
||||
Pass "no-cors" Headers object cannot have rtt/1.0 as header
|
||||
Pass "no-cors" Headers object cannot have downlink/-1.0 as header
|
||||
Pass "no-cors" Headers object cannot have ect/6g as header
|
||||
Pass "no-cors" Headers object cannot have save-data/on as header
|
||||
Pass "no-cors" Headers object cannot have viewport-width/100 as header
|
||||
Pass "no-cors" Headers object cannot have width/100 as header
|
||||
Pass "no-cors" Headers object cannot have unknown/doesitmatter as header
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
[
|
||||
["accept", "\""],
|
||||
["accept", "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678"],
|
||||
["accept-language", "\u0001"],
|
||||
["accept-language", "@"],
|
||||
["authorization", "basics"],
|
||||
["content-language", "\u0001"],
|
||||
["content-language", "@"],
|
||||
["content-type", "text/html"],
|
||||
["content-type", "text/plain; long=0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901"],
|
||||
["range", "bytes 0-"],
|
||||
["test", "hi"]
|
||||
]
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
|
||||
<script>
|
||||
self.GLOBAL = {
|
||||
isWindow: function() { return true; },
|
||||
isWorker: function() { return false; },
|
||||
isShadowRealm: function() { return false; },
|
||||
};
|
||||
</script>
|
||||
<script src="../../../resources/testharness.js"></script>
|
||||
<script src="../../../resources/testharnessreport.js"></script>
|
||||
|
||||
<div id=log></div>
|
||||
<script src="../../../fetch/api/headers/headers-no-cors.any.js"></script>
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
// META: global=window,worker
|
||||
|
||||
"use strict";
|
||||
|
||||
promise_test(() => fetch("../cors/resources/not-cors-safelisted.json").then(res => res.json().then(runTests)), "Loading data…");
|
||||
|
||||
const longValue = "s".repeat(127);
|
||||
|
||||
[
|
||||
{
|
||||
"headers": ["accept", "accept-language", "content-language"],
|
||||
"values": [longValue, "", longValue]
|
||||
},
|
||||
{
|
||||
"headers": ["accept", "accept-language", "content-language"],
|
||||
"values": ["", longValue]
|
||||
},
|
||||
{
|
||||
"headers": ["content-type"],
|
||||
"values": ["text/plain;" + "s".repeat(116), "text/plain"]
|
||||
}
|
||||
].forEach(testItem => {
|
||||
testItem.headers.forEach(header => {
|
||||
test(() => {
|
||||
const noCorsHeaders = new Request("about:blank", { mode: "no-cors" }).headers;
|
||||
testItem.values.forEach((value) => {
|
||||
noCorsHeaders.append(header, value);
|
||||
assert_equals(noCorsHeaders.get(header), testItem.values[0], '1');
|
||||
});
|
||||
noCorsHeaders.set(header, testItem.values.join(", "));
|
||||
assert_equals(noCorsHeaders.get(header), testItem.values[0], '2');
|
||||
noCorsHeaders.delete(header);
|
||||
assert_false(noCorsHeaders.has(header));
|
||||
}, "\"no-cors\" Headers object cannot have " + header + " set to " + testItem.values.join(", "));
|
||||
});
|
||||
});
|
||||
|
||||
function runTests(testArray) {
|
||||
testArray = testArray.concat([
|
||||
["dpr", "2"],
|
||||
["rtt", "1.0"],
|
||||
["downlink", "-1.0"],
|
||||
["ect", "6g"],
|
||||
["save-data", "on"],
|
||||
["viewport-width", "100"],
|
||||
["width", "100"],
|
||||
["unknown", "doesitmatter"]
|
||||
]);
|
||||
testArray.forEach(testItem => {
|
||||
const [headerName, headerValue] = testItem;
|
||||
test(() => {
|
||||
const noCorsHeaders = new Request("about:blank", { mode: "no-cors" }).headers;
|
||||
noCorsHeaders.append(headerName, headerValue);
|
||||
assert_false(noCorsHeaders.has(headerName));
|
||||
noCorsHeaders.set(headerName, headerValue);
|
||||
assert_false(noCorsHeaders.has(headerName));
|
||||
}, "\"no-cors\" Headers object cannot have " + headerName + "/" + headerValue + " as header");
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue