mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:07:36 +00:00
Browser+LibWeb+WebContent: Track the source of document.cookie requests
To implement the HttpOnly attribute, the CookieJar needs to know where a request originated from. Namely, it needs to distinguish between HTTP / non-HTTP (i.e. JavaScript) requests. When the HttpOnly attribute is set, requests from JavaScript are to be blocked.
This commit is contained in:
parent
7193e518d1
commit
c00760c5f9
20 changed files with 54 additions and 47 deletions
|
@ -821,17 +821,17 @@ void Document::completely_finish_loading()
|
|||
dispatch_event(DOM::Event::create(HTML::EventNames::load));
|
||||
}
|
||||
|
||||
String Document::cookie()
|
||||
String Document::cookie(Cookie::Source source)
|
||||
{
|
||||
if (auto* page = this->page())
|
||||
return page->client().page_did_request_cookie(m_url);
|
||||
return page->client().page_did_request_cookie(m_url, source);
|
||||
return {};
|
||||
}
|
||||
|
||||
void Document::set_cookie(String cookie)
|
||||
void Document::set_cookie(String cookie, Cookie::Source source)
|
||||
{
|
||||
if (auto* page = this->page())
|
||||
page->client().page_did_set_cookie(m_url, cookie);
|
||||
page->client().page_did_set_cookie(m_url, cookie, source);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include <LibWeb/CSS/CSSStyleSheet.h>
|
||||
#include <LibWeb/CSS/StyleResolver.h>
|
||||
#include <LibWeb/CSS/StyleSheetList.h>
|
||||
#include <LibWeb/Cookie/Cookie.h>
|
||||
#include <LibWeb/DOM/DOMImplementation.h>
|
||||
#include <LibWeb/DOM/ExceptionOr.h>
|
||||
#include <LibWeb/DOM/NonElementParentNode.h>
|
||||
|
@ -73,8 +74,8 @@ public:
|
|||
|
||||
virtual ~Document() override;
|
||||
|
||||
String cookie();
|
||||
void set_cookie(String);
|
||||
String cookie(Cookie::Source = Cookie::Source::NonHttp);
|
||||
void set_cookie(String, Cookie::Source = Cookie::Source::NonHttp);
|
||||
|
||||
bool should_invalidate_styles_on_attribute_changes() const { return m_should_invalidate_styles_on_attribute_changes; }
|
||||
void set_should_invalidate_styles_on_attribute_changes(bool b) { m_should_invalidate_styles_on_attribute_changes = b; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue