@@ -90,7 +90,7 @@ String CookieJar::get_cookie(const URL::URL& url, Web::Cookie::Source source)
9090{
9191 m_transient_storage.purge_expired_cookies ();
9292
93- auto domain = canonicalize_domain (url);
93+ auto domain = Web::Cookie:: canonicalize_domain (url);
9494 if (!domain.has_value ())
9595 return {};
9696
@@ -119,7 +119,7 @@ String CookieJar::get_cookie(const URL::URL& url, Web::Cookie::Source source)
119119
120120void CookieJar::set_cookie (const URL::URL& url, Web::Cookie::ParsedCookie const & parsed_cookie, Web::Cookie::Source source)
121121{
122- auto domain = canonicalize_domain (url);
122+ auto domain = Web::Cookie:: canonicalize_domain (url);
123123 if (!domain.has_value ())
124124 return ;
125125
@@ -194,7 +194,7 @@ Vector<Web::Cookie::Cookie> CookieJar::get_all_cookies()
194194// https://w3c.github.io/webdriver/#dfn-associated-cookies
195195Vector<Web::Cookie::Cookie> CookieJar::get_all_cookies_webdriver (URL::URL const & url)
196196{
197- auto domain = canonicalize_domain (url);
197+ auto domain = Web::Cookie:: canonicalize_domain (url);
198198 if (!domain.has_value ())
199199 return {};
200200
@@ -203,7 +203,7 @@ Vector<Web::Cookie::Cookie> CookieJar::get_all_cookies_webdriver(URL::URL const&
203203
204204Vector<Web::Cookie::Cookie> CookieJar::get_all_cookies_cookiestore (URL::URL const & url)
205205{
206- auto domain = canonicalize_domain (url);
206+ auto domain = Web::Cookie:: canonicalize_domain (url);
207207 if (!domain.has_value ())
208208 return {};
209209
@@ -212,7 +212,7 @@ Vector<Web::Cookie::Cookie> CookieJar::get_all_cookies_cookiestore(URL::URL cons
212212
213213Optional<Web::Cookie::Cookie> CookieJar::get_named_cookie (URL::URL const & url, StringView name)
214214{
215- auto domain = canonicalize_domain (url);
215+ auto domain = Web::Cookie:: canonicalize_domain (url);
216216 if (!domain.has_value ())
217217 return {};
218218
@@ -231,45 +231,6 @@ void CookieJar::expire_cookies_with_time_offset(AK::Duration offset)
231231 m_transient_storage.purge_expired_cookies (offset);
232232}
233233
234- // https://www.ietf.org/archive/id/draft-ietf-httpbis-rfc6265bis-15.html#section-5.1.2
235- Optional<String> CookieJar::canonicalize_domain (const URL::URL& url)
236- {
237- if (!url.host ().has_value ())
238- return {};
239-
240- // 1. Convert the host name to a sequence of individual domain name labels.
241- // 2. Convert each label that is not a Non-Reserved LDH (NR-LDH) label, to an A-label (see Section 2.3.2.1 of
242- // [RFC5890] for the former and latter), or to a "punycode label" (a label resulting from the "ToASCII" conversion
243- // in Section 4 of [RFC3490]), as appropriate (see Section 6.3 of this specification).
244- // 3. Concatenate the resulting labels, separated by a %x2E (".") character.
245- // FIXME: Implement the above conversions.
246-
247- return MUST (url.serialized_host ().to_lowercase ());
248- }
249-
250- // https://www.ietf.org/archive/id/draft-ietf-httpbis-rfc6265bis-15.html#section-5.1.4
251- bool CookieJar::path_matches (StringView request_path, StringView cookie_path)
252- {
253- // A request-path path-matches a given cookie-path if at least one of the following conditions holds:
254-
255- // * The cookie-path and the request-path are identical.
256- if (request_path == cookie_path)
257- return true ;
258-
259- if (request_path.starts_with (cookie_path)) {
260- // * The cookie-path is a prefix of the request-path, and the last character of the cookie-path is %x2F ("/").
261- if (cookie_path.ends_with (' /' ))
262- return true ;
263-
264- // * The cookie-path is a prefix of the request-path, and the first character of the request-path that is not
265- // included in the cookie-path is a %x2F ("/") character.
266- if (request_path[cookie_path.length ()] == ' /' )
267- return true ;
268- }
269-
270- return false ;
271- }
272-
273234// https://www.ietf.org/archive/id/draft-ietf-httpbis-rfc6265bis-15.html#name-storage-model
274235void CookieJar::store_cookie (Web::Cookie::ParsedCookie const & parsed_cookie, const URL::URL& url, String canonicalized_domain, Web::Cookie::Source source)
275236{
@@ -433,7 +394,7 @@ void CookieJar::store_cookie(Web::Cookie::ParsedCookie const& parsed_cookie, con
433394 return IterationDecision::Continue;
434395
435396 // 4. The path of the newly-created cookie path-matches the path of the existing cookie.
436- if (!path_matches (cookie.path , old_cookie.path ))
397+ if (!Web::Cookie:: path_matches (cookie.path , old_cookie.path ))
437398 return IterationDecision::Continue;
438399
439400 ignore_cookie = true ;
@@ -561,7 +522,7 @@ Vector<Web::Cookie::Cookie> CookieJar::get_matching_cookies(const URL::URL& url,
561522 return ;
562523
563524 // * The retrieval's URI's path path-matches the cookie's path.
564- if (!path_matches (url.serialize_path (), cookie.path ))
525+ if (!Web::Cookie:: path_matches (url.serialize_path (), cookie.path ))
565526 return ;
566527
567528 // * If the cookie's secure-only-flag is true, then the retrieval's URI must denote a "secure" connection (as
0 commit comments