mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 09:09:43 +00:00
LibWeb+LibURL: Move HTML::Origin to URL::Origin
While Origin is defined in the HTML spec - this leaves us with quite an awkward relationship as the URL spec makes use of AO's from what is defined in the HTML spec. To simplify this factoring, relocate Origin into LibURL.
This commit is contained in:
parent
e9dd05b2b5
commit
dc401f49ea
Notes:
github-actions[bot]
2024-10-05 08:47:56 +00:00
Author: https://github.com/shannonbooth
Commit: dc401f49ea
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1636
55 changed files with 143 additions and 157 deletions
|
@ -172,7 +172,7 @@ bool Request::has_redirect_tainted_origin() const
|
|||
}
|
||||
|
||||
// 2. If url’s origin is not same origin with lastURL’s origin and request’s origin is not same origin with lastURL’s origin, then return true.
|
||||
auto const* request_origin = m_origin.get_pointer<HTML::Origin>();
|
||||
auto const* request_origin = m_origin.get_pointer<URL::Origin>();
|
||||
if (!DOMURL::url_origin(url).is_same_origin(DOMURL::url_origin(*last_url))
|
||||
&& (request_origin == nullptr || !request_origin->is_same_origin(DOMURL::url_origin(*last_url)))) {
|
||||
return true;
|
||||
|
@ -194,7 +194,7 @@ String Request::serialize_origin() const
|
|||
return "null"_string;
|
||||
|
||||
// 2. Return request’s origin, serialized.
|
||||
return MUST(String::from_byte_string(m_origin.get<HTML::Origin>().serialize()));
|
||||
return MUST(String::from_byte_string(m_origin.get<URL::Origin>().serialize()));
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#byte-serializing-a-request-origin
|
||||
|
@ -321,14 +321,14 @@ void Request::add_origin_header()
|
|||
case ReferrerPolicy::ReferrerPolicy::StrictOriginWhenCrossOrigin:
|
||||
// If request’s origin is a tuple origin, its scheme is "https", and request’s current URL’s scheme is
|
||||
// not "https", then set serializedOrigin to `null`.
|
||||
if (m_origin.has<HTML::Origin>() && m_origin.get<HTML::Origin>().scheme() == "https"sv && current_url().scheme() != "https"sv)
|
||||
if (m_origin.has<URL::Origin>() && m_origin.get<URL::Origin>().scheme() == "https"sv && current_url().scheme() != "https"sv)
|
||||
serialized_origin = MUST(ByteBuffer::copy("null"sv.bytes()));
|
||||
break;
|
||||
// -> "same-origin"
|
||||
case ReferrerPolicy::ReferrerPolicy::SameOrigin:
|
||||
// If request’s origin is not same origin with request’s current URL’s origin, then set serializedOrigin
|
||||
// to `null`.
|
||||
if (m_origin.has<HTML::Origin>() && !m_origin.get<HTML::Origin>().is_same_origin(DOMURL::url_origin(current_url())))
|
||||
if (m_origin.has<URL::Origin>() && !m_origin.get<URL::Origin>().is_same_origin(DOMURL::url_origin(current_url())))
|
||||
serialized_origin = MUST(ByteBuffer::copy("null"sv.bytes()));
|
||||
break;
|
||||
// -> Otherwise
|
||||
|
@ -364,7 +364,7 @@ bool Request::cross_origin_embedder_policy_allows_credentials() const
|
|||
|
||||
// 4. If request’s origin is same origin with request’s current URL’s origin and request does not have a redirect-tainted origin, then return true.
|
||||
// 5. Return false.
|
||||
auto const* request_origin = m_origin.get_pointer<HTML::Origin>();
|
||||
auto const* request_origin = m_origin.get_pointer<URL::Origin>();
|
||||
if (request_origin == nullptr)
|
||||
return false;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue