mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 09:17:45 +00:00
Browser+LibWeb: Move cookie parser into LibWeb
This moves the cookie parsing steps out of CookieJar into their own file inside LibWeb. It makes sense for the cookie structures to be in LibWeb for a couple reasons: 1. There are some steps in the spec that will need to partially happen from LibWeb, such as the HttpOnly attribute. 2. Parsing the cookie string will be safer if it happens in the OOP tab rather than the main Browser process. Then if the parser blows up due to a malformed cookie, only that tab will be affected. 3. Cookies in general are a Web concept not specific to a browser.
This commit is contained in:
parent
7702a3fe29
commit
c2d38abe6f
6 changed files with 428 additions and 355 deletions
|
@ -31,6 +31,7 @@
|
|||
#include <AK/String.h>
|
||||
#include <AK/Traits.h>
|
||||
#include <LibCore/DateTime.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Browser {
|
||||
|
||||
|
@ -48,8 +49,6 @@ struct Cookie {
|
|||
bool persistent { false };
|
||||
};
|
||||
|
||||
struct ParsedCookie;
|
||||
|
||||
struct CookieStorageKey {
|
||||
bool operator==(const CookieStorageKey&) const = default;
|
||||
|
||||
|
@ -66,20 +65,10 @@ public:
|
|||
|
||||
private:
|
||||
static Optional<String> canonicalize_domain(const URL& url);
|
||||
static String default_path(const URL& url);
|
||||
static Optional<ParsedCookie> parse_cookie(const String& cookie_string);
|
||||
static void parse_attributes(ParsedCookie& parsed_cookie, StringView unparsed_attributes);
|
||||
static void process_attribute(ParsedCookie& parsed_cookie, StringView attribute_name, StringView attribute_value);
|
||||
static void on_expires_attribute(ParsedCookie& parsed_cookie, StringView attribute_value);
|
||||
static void on_max_age_attribute(ParsedCookie& parsed_cookie, StringView attribute_value);
|
||||
static void on_domain_attribute(ParsedCookie& parsed_cookie, StringView attribute_value);
|
||||
static void on_path_attribute(ParsedCookie& parsed_cookie, StringView attribute_value);
|
||||
static void on_secure_attribute(ParsedCookie& parsed_cookie);
|
||||
static void on_http_only_attribute(ParsedCookie& parsed_cookie);
|
||||
static Optional<Core::DateTime> parse_date_time(StringView date_string);
|
||||
static bool domain_matches(const String& string, const String& domain_string);
|
||||
static String default_path(const URL& url);
|
||||
|
||||
void store_cookie(ParsedCookie& parsed_cookie, const URL& url, String canonicalized_domain);
|
||||
void store_cookie(Web::Cookie::ParsedCookie& parsed_cookie, const URL& url, String canonicalized_domain);
|
||||
void purge_expired_cookies();
|
||||
|
||||
HashMap<CookieStorageKey, Cookie> m_cookies;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue