From cb480fa3dc4f88a222732c04ee6ff96899a38555 Mon Sep 17 00:00:00 2001 From: Smrtnyk Date: Fri, 21 Oct 2022 13:01:06 +0200 Subject: [PATCH] Browser: Show SameSite attribute in cookie storage inspector --- Userland/Applications/Browser/CookieJar.cpp | 3 ++- Userland/Applications/Browser/CookiesModel.cpp | 4 ++++ Userland/Applications/Browser/CookiesModel.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Userland/Applications/Browser/CookieJar.cpp b/Userland/Applications/Browser/CookieJar.cpp index d2f2500529..d0c3df10a6 100644 --- a/Userland/Applications/Browser/CookieJar.cpp +++ b/Userland/Applications/Browser/CookieJar.cpp @@ -99,6 +99,7 @@ void CookieJar::dump_cookies() const builder.appendff("\t{}HttpOnly{} = {:s}\n", attribute_color, no_color, cookie.value.http_only); builder.appendff("\t{}HostOnly{} = {:s}\n", attribute_color, no_color, cookie.value.host_only); builder.appendff("\t{}Persistent{} = {:s}\n", attribute_color, no_color, cookie.value.persistent); + builder.appendff("\t{}SameSite{} = {:s}\n", attribute_color, no_color, Web::Cookie::same_site_to_string(cookie.value.same_site)); } dbgln("{}", builder.build()); @@ -199,7 +200,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 { parsed_cookie.name, parsed_cookie.value }; + Web::Cookie::Cookie cookie { parsed_cookie.name, parsed_cookie.value, parsed_cookie.same_site_attribute }; cookie.creation_time = Core::DateTime::now(); cookie.last_access_time = cookie.creation_time; diff --git a/Userland/Applications/Browser/CookiesModel.cpp b/Userland/Applications/Browser/CookiesModel.cpp index bea2296509..a3ad8ffccc 100644 --- a/Userland/Applications/Browser/CookiesModel.cpp +++ b/Userland/Applications/Browser/CookiesModel.cpp @@ -47,6 +47,8 @@ String CookiesModel::column_name(int column) const return "Value"; case Column::ExpiryTime: return "Expiry time"; + case Column::SameSite: + return "SameSite"; case Column::__Count: return {}; } @@ -79,6 +81,8 @@ GUI::Variant CookiesModel::data(GUI::ModelIndex const& index, GUI::ModelRole rol return cookie.value; case Column::ExpiryTime: return cookie.expiry_time.to_string(); + case Column::SameSite: + return Web::Cookie::same_site_to_string(cookie.same_site); } VERIFY_NOT_REACHED(); diff --git a/Userland/Applications/Browser/CookiesModel.h b/Userland/Applications/Browser/CookiesModel.h index 4c378115a2..0fd8241344 100644 --- a/Userland/Applications/Browser/CookiesModel.h +++ b/Userland/Applications/Browser/CookiesModel.h @@ -22,6 +22,7 @@ public: Name, Value, ExpiryTime, + SameSite, __Count, };