diff --git a/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp b/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp index 594763afd2..725967073c 100644 --- a/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp +++ b/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include namespace Web::Cookie { @@ -75,7 +76,7 @@ Optional parse_cookie(StringView cookie_string) return {}; // 6. The cookie-name is the name string, and the cookie-value is the value string. - ParsedCookie parsed_cookie { name, value }; + ParsedCookie parsed_cookie { MUST(String::from_utf8(name)), MUST(String::from_utf8(value)) }; parse_attributes(parsed_cookie, unparsed_attributes); return parsed_cookie; @@ -197,7 +198,7 @@ void on_domain_attribute(ParsedCookie& parsed_cookie, StringView attribute_value } // Convert the cookie-domain to lower case. - parsed_cookie.domain = DeprecatedString(cookie_domain).to_lowercase(); + parsed_cookie.domain = MUST(Infra::to_ascii_lowercase(cookie_domain)); } void on_path_attribute(ParsedCookie& parsed_cookie, StringView attribute_value) @@ -210,7 +211,7 @@ void on_path_attribute(ParsedCookie& parsed_cookie, StringView attribute_value) return; // Let cookie-path be the attribute-value - parsed_cookie.path = attribute_value; + parsed_cookie.path = MUST(String::from_utf8(attribute_value)); } void on_secure_attribute(ParsedCookie& parsed_cookie) @@ -373,12 +374,12 @@ ErrorOr IPC::encode(Encoder& encoder, Web::Cookie::ParsedCookie const& coo template<> ErrorOr IPC::decode(Decoder& decoder) { - auto name = TRY(decoder.decode()); - auto value = TRY(decoder.decode()); + auto name = TRY(decoder.decode()); + auto value = TRY(decoder.decode()); auto expiry_time_from_expires_attribute = TRY(decoder.decode>()); auto expiry_time_from_max_age_attribute = TRY(decoder.decode>()); - auto domain = TRY(decoder.decode>()); - auto path = TRY(decoder.decode>()); + auto domain = TRY(decoder.decode>()); + auto path = TRY(decoder.decode>()); auto secure_attribute_present = TRY(decoder.decode()); auto http_only_attribute_present = TRY(decoder.decode()); auto same_site_attribute = TRY(decoder.decode()); diff --git a/Userland/Libraries/LibWeb/Cookie/ParsedCookie.h b/Userland/Libraries/LibWeb/Cookie/ParsedCookie.h index 5ffb185fba..3108896468 100644 --- a/Userland/Libraries/LibWeb/Cookie/ParsedCookie.h +++ b/Userland/Libraries/LibWeb/Cookie/ParsedCookie.h @@ -6,8 +6,8 @@ #pragma once -#include #include +#include #include #include #include @@ -15,13 +15,13 @@ namespace Web::Cookie { struct ParsedCookie { - DeprecatedString name; - DeprecatedString value; + String name; + String value; SameSite same_site_attribute { SameSite::Default }; Optional expiry_time_from_expires_attribute {}; Optional expiry_time_from_max_age_attribute {}; - Optional domain {}; - Optional path {}; + Optional domain {}; + Optional path {}; bool secure_attribute_present { false }; bool http_only_attribute_present { false }; }; diff --git a/Userland/Libraries/LibWebView/CookieJar.cpp b/Userland/Libraries/LibWebView/CookieJar.cpp index a9a48d004e..55f7a2c851 100644 --- a/Userland/Libraries/LibWebView/CookieJar.cpp +++ b/Userland/Libraries/LibWebView/CookieJar.cpp @@ -290,7 +290,7 @@ void CookieJar::store_cookie(Web::Cookie::ParsedCookie const& parsed_cookie, con // https://tools.ietf.org/html/rfc6265#section-5.3 // 2. Create a new cookie with name cookie-name, value cookie-value. Set the creation-time and the last-access-time to the current date and time. - Web::Cookie::Cookie cookie { MUST(String::from_deprecated_string(parsed_cookie.name)), MUST(String::from_deprecated_string(parsed_cookie.value)), parsed_cookie.same_site_attribute }; + Web::Cookie::Cookie cookie { parsed_cookie.name, parsed_cookie.value, parsed_cookie.same_site_attribute }; cookie.creation_time = UnixDateTime::now(); cookie.last_access_time = cookie.creation_time; @@ -313,7 +313,7 @@ void CookieJar::store_cookie(Web::Cookie::ParsedCookie const& parsed_cookie, con // 4. If the cookie-attribute-list contains an attribute with an attribute-name of "Domain": if (parsed_cookie.domain.has_value()) { // Let the domain-attribute be the attribute-value of the last attribute in the cookie-attribute-list with an attribute-name of "Domain". - cookie.domain = MUST(String::from_deprecated_string(parsed_cookie.domain.value())); + cookie.domain = parsed_cookie.domain.value(); } // 5. If the user agent is configured to reject "public suffixes" and the domain-attribute is a public suffix: @@ -347,7 +347,7 @@ void CookieJar::store_cookie(Web::Cookie::ParsedCookie const& parsed_cookie, con // 7. If the cookie-attribute-list contains an attribute with an attribute-name of "Path": if (parsed_cookie.path.has_value()) { // Set the cookie's path to attribute-value of the last attribute in the cookie-attribute-list with an attribute-name of "Path". - cookie.path = MUST(String::from_deprecated_string(parsed_cookie.path.value())); + cookie.path = parsed_cookie.path.value(); } else { cookie.path = MUST(String::from_deprecated_string(default_path(url))); } diff --git a/Userland/Services/WebContent/WebDriverConnection.cpp b/Userland/Services/WebContent/WebDriverConnection.cpp index 19c27b0f5e..031798acb9 100644 --- a/Userland/Services/WebContent/WebDriverConnection.cpp +++ b/Userland/Services/WebContent/WebDriverConnection.cpp @@ -1570,21 +1570,21 @@ Messages::WebDriverClient::AddCookieResponse WebDriverConnection::add_cookie(Jso // 7. Create a cookie in the cookie store associated with the active document’s address using cookie name name, cookie value value, and an attribute-value list of the following cookie concepts listed in the table for cookie conversion from data: Web::Cookie::ParsedCookie cookie {}; - cookie.name = TRY(get_property(data, "name"sv)); - cookie.value = TRY(get_property(data, "value"sv)); + cookie.name = MUST(String::from_deprecated_string(TRY(get_property(data, "name"sv)))); + cookie.value = MUST(String::from_deprecated_string(TRY(get_property(data, "value"sv)))); // Cookie path // The value if the entry exists, otherwise "/". if (data.has("path"sv)) - cookie.path = TRY(get_property(data, "path"sv)); + cookie.path = MUST(String::from_deprecated_string(TRY(get_property(data, "path"sv)))); else - cookie.path = "/"; + cookie.path = "/"_string; // Cookie domain // The value if the entry exists, otherwise the current browsing context’s active document’s URL domain. // NOTE: The otherwise case is handled by the CookieJar if (data.has("domain"sv)) - cookie.domain = TRY(get_property(data, "domain"sv)); + cookie.domain = MUST(String::from_deprecated_string(TRY(get_property(data, "domain"sv)))); // Cookie secure only // The value if the entry exists, otherwise false.