mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 17:44:56 +09:00
LibWebView: Ensure manually expired cookies are purged from the database
Cookies are typically deleted by setting their expiry time to an ancient time stamp (i.e. this is how WebDriver is required to delete cookies). Previously, we would update the cookie in the cookie jar, which would mark the cookie as dirty. We would then purge expired cookies from the jar's transient storage, which removed the cookie from the dirty list. If the cookie was also in the persisted storage, it would never become expired there as it was no longer in the dirty list when the timer for synchronization fired. Now, we don't remove any cookies from the transient dirty list when we purge expired cookies. We hold onto the dirty cookie until sync time, where we now update the cookie in the persisted storage *before* we delete expired cookies.
This commit is contained in:
parent
2c35e272ba
commit
693af180dd
Notes:
github-actions[bot]
2024-09-07 09:11:49 +00:00
Author: https://github.com/trflynn89
Commit: 693af180dd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1302
1 changed files with 3 additions and 5 deletions
|
@ -68,11 +68,11 @@ CookieJar::CookieJar(Optional<PersistedStorage> persisted_storage)
|
||||||
m_persisted_storage->synchronization_timer = Core::Timer::create_repeating(
|
m_persisted_storage->synchronization_timer = Core::Timer::create_repeating(
|
||||||
static_cast<int>(DATABASE_SYNCHRONIZATION_TIMER.to_milliseconds()),
|
static_cast<int>(DATABASE_SYNCHRONIZATION_TIMER.to_milliseconds()),
|
||||||
[this]() {
|
[this]() {
|
||||||
auto now = m_transient_storage.purge_expired_cookies();
|
|
||||||
m_persisted_storage->database.execute_statement(m_persisted_storage->statements.expire_cookie, {}, now);
|
|
||||||
|
|
||||||
for (auto const& it : m_transient_storage.take_dirty_cookies())
|
for (auto const& it : m_transient_storage.take_dirty_cookies())
|
||||||
m_persisted_storage->insert_cookie(it.value);
|
m_persisted_storage->insert_cookie(it.value);
|
||||||
|
|
||||||
|
auto now = m_transient_storage.purge_expired_cookies();
|
||||||
|
m_persisted_storage->database.execute_statement(m_persisted_storage->statements.expire_cookie, {}, now);
|
||||||
});
|
});
|
||||||
m_persisted_storage->synchronization_timer->start();
|
m_persisted_storage->synchronization_timer->start();
|
||||||
}
|
}
|
||||||
|
@ -471,8 +471,6 @@ UnixDateTime CookieJar::TransientStorage::purge_expired_cookies()
|
||||||
auto is_expired = [&](auto const&, auto const& cookie) { return cookie.expiry_time < now; };
|
auto is_expired = [&](auto const&, auto const& cookie) { return cookie.expiry_time < now; };
|
||||||
|
|
||||||
m_cookies.remove_all_matching(is_expired);
|
m_cookies.remove_all_matching(is_expired);
|
||||||
m_dirty_cookies.remove_all_matching(is_expired);
|
|
||||||
|
|
||||||
return now;
|
return now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue