LibWebView: Let Settings clear HSTS policies
This commit is contained in:
parent
f6e5af0cb5
commit
9be221abff
3 changed files with 21 additions and 0 deletions
|
|
@ -1203,6 +1203,7 @@ void Application::clear_browsing_data(ClearBrowsingDataOptions const& options)
|
|||
if (options.delete_site_data == ClearBrowsingDataOptions::Delete::Yes) {
|
||||
m_cookie_jar->expire_cookies_accessed_since(options.since);
|
||||
m_storage_jar->remove_items_accessed_since(options.since);
|
||||
m_hsts_store->remove_policies_observed_since(options.since);
|
||||
}
|
||||
|
||||
if (did_change_history)
|
||||
|
|
|
|||
|
|
@ -134,6 +134,11 @@ bool HSTSStore::is_known_hsts_host(StringView domain)
|
|||
return false;
|
||||
}
|
||||
|
||||
void HSTSStore::remove_policies_observed_since(UnixDateTime since)
|
||||
{
|
||||
m_transient_storage.remove_policies_observed_since(since);
|
||||
}
|
||||
|
||||
void HSTSStore::TransientStorage::set_policies(Policies policies)
|
||||
{
|
||||
m_policies = move(policies);
|
||||
|
|
@ -168,6 +173,18 @@ void HSTSStore::TransientStorage::update_last_observed_time(StringView domain)
|
|||
m_dirty_policies.set(it->key, it->value);
|
||||
}
|
||||
|
||||
void HSTSStore::TransientStorage::remove_policies_observed_since(UnixDateTime since)
|
||||
{
|
||||
for (auto& [domain, policy] : m_policies) {
|
||||
if (policy.last_observed_time >= since) {
|
||||
policy.expiry = UnixDateTime::earliest();
|
||||
m_dirty_policies.set(domain, policy);
|
||||
}
|
||||
}
|
||||
|
||||
purge_expired_policies();
|
||||
}
|
||||
|
||||
UnixDateTime HSTSStore::TransientStorage::purge_expired_policies()
|
||||
{
|
||||
// A Known HSTS Host is "expired" if its cache entry has an expiry date
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ public:
|
|||
// https://www.rfc-editor.org/rfc/rfc6797#section-8.2
|
||||
bool is_known_hsts_host(StringView domain);
|
||||
|
||||
void remove_policies_observed_since(UnixDateTime since);
|
||||
|
||||
private:
|
||||
struct StoredPolicy {
|
||||
UnixDateTime expiry;
|
||||
|
|
@ -52,6 +54,7 @@ private:
|
|||
void update_last_observed_time(StringView domain);
|
||||
|
||||
UnixDateTime purge_expired_policies();
|
||||
void remove_policies_observed_since(UnixDateTime since);
|
||||
|
||||
auto take_dirty_policies() { return move(m_dirty_policies); }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue