mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:17:45 +00:00
LibWeb: Add a string-to-same-site-attribute converter
This commit is contained in:
parent
a3d6c2f6af
commit
fce9fcf154
3 changed files with 13 additions and 7 deletions
|
@ -25,6 +25,17 @@ StringView same_site_to_string(SameSite same_site)
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
SameSite same_site_from_string(StringView same_site_mode)
|
||||
{
|
||||
if (same_site_mode.equals_ignoring_case("None"sv))
|
||||
return SameSite::None;
|
||||
if (same_site_mode.equals_ignoring_case("Strict"sv))
|
||||
return SameSite::Strict;
|
||||
if (same_site_mode.equals_ignoring_case("Lax"sv))
|
||||
return SameSite::Lax;
|
||||
return SameSite::Default;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool IPC::encode(Encoder& encoder, Web::Cookie::Cookie const& cookie)
|
||||
|
|
|
@ -40,6 +40,7 @@ struct Cookie {
|
|||
};
|
||||
|
||||
StringView same_site_to_string(SameSite same_site_mode);
|
||||
SameSite same_site_from_string(StringView same_site_mode);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -229,17 +229,11 @@ void on_http_only_attribute(ParsedCookie& parsed_cookie)
|
|||
void on_same_site_attribute(ParsedCookie& parsed_cookie, StringView attribute_value)
|
||||
{
|
||||
// 1. Let enforcement be "Default"
|
||||
// Note: Set as default value in ParsedCookie.h
|
||||
|
||||
// 2. If cookie-av's attribute-value is a case-insensitive match for "None", set enforcement to "None".
|
||||
if (attribute_value.equals_ignoring_case("None"sv))
|
||||
parsed_cookie.same_site_attribute = SameSite::None;
|
||||
// 3. If cookie-av's attribute-value is a case-insensitive match for "Strict", set enforcement to "Strict".
|
||||
else if (attribute_value.equals_ignoring_case("Strict"sv))
|
||||
parsed_cookie.same_site_attribute = SameSite::Strict;
|
||||
// 4. If cookie-av's attribute-value is a case-insensitive match for "Lax", set enforcement to "Lax".
|
||||
else if (attribute_value.equals_ignoring_case("Lax"sv))
|
||||
parsed_cookie.same_site_attribute = SameSite::Lax;
|
||||
parsed_cookie.same_site_attribute = same_site_from_string(attribute_value);
|
||||
}
|
||||
|
||||
Optional<Core::DateTime> parse_date_time(StringView date_string)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue