LibWeb: Set Sec-Fetch-Site header to same-site where appropriate

This also fixes it looking at the request's current URL origin instead
of the request's actual origin.
This commit is contained in:
Luke Wilde 2025-01-28 19:10:32 +00:00 committed by Andreas Kling
parent f8cc990bcd
commit b35979c3f7
Notes: github-actions[bot] 2025-01-30 20:57:30 +00:00

View file

@ -2722,17 +2722,23 @@ void set_sec_fetch_site_header(Infrastructure::Request& request)
// 5. If headers value is not none, then for each url in rs url list:
if (!header_value.equals_ignoring_ascii_case("none"sv)) {
VERIFY(request.origin().has<URL::Origin>());
auto& request_origin = request.origin().get<URL::Origin>();
for (auto& url : request.url_list()) {
// 1. If url is same origin with rs origin, continue.
if (url.origin().is_same_origin(request.current_url().origin()))
if (url.origin().is_same_origin(request_origin))
continue;
// 2. Set headers value to cross-site.
header_value = "cross-site"sv;
// FIXME: 3. If rs origin is not same site with urls origin, then break.
// 3. If rs origin is not same site with urls origin, then break.
if (!request_origin.is_same_site(url.origin()))
break;
// FIXME: 4. Set headers value to same-site.
// 4. Set headers value to same-site.
header_value = "same-site"sv;
}
}