mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-15 23:09:05 +00:00
Browser+LibWeb+WebContent: Parse cookies in the OOP tab
To protect the main Browser process against nefarious cookies, parse the cookies out-of-process and then send the parsed result over IPC to the main process. This way, if the cookie parser blows up, only that tab will be affected.
This commit is contained in:
parent
6e10c2cdb7
commit
2381b19719
Notes:
sideshowbarker
2024-07-18 20:15:44 +09:00
Author: https://github.com/trflynn89
Commit: 2381b19719
Pull-request: https://github.com/SerenityOS/serenity/pull/6349
Reviewed-by: https://github.com/awesomekling
19 changed files with 79 additions and 26 deletions
|
@ -25,7 +25,10 @@
|
|||
*/
|
||||
|
||||
#include "ParsedCookie.h"
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibIPC/Decoder.h>
|
||||
#include <LibIPC/Encoder.h>
|
||||
#include <ctype.h>
|
||||
|
||||
namespace Web::Cookie {
|
||||
|
@ -351,3 +354,39 @@ Optional<Core::DateTime> parse_date_time(StringView date_string)
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
bool IPC::encode(IPC::Encoder& encoder, const Web::Cookie::ParsedCookie& cookie)
|
||||
{
|
||||
encoder << cookie.name;
|
||||
encoder << cookie.value;
|
||||
encoder << cookie.expiry_time_from_expires_attribute;
|
||||
encoder << cookie.expiry_time_from_max_age_attribute;
|
||||
encoder << cookie.domain;
|
||||
encoder << cookie.path;
|
||||
encoder << cookie.secure_attribute_present;
|
||||
encoder << cookie.http_only_attribute_present;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IPC::decode(IPC::Decoder& decoder, Web::Cookie::ParsedCookie& cookie)
|
||||
{
|
||||
if (!decoder.decode(cookie.name))
|
||||
return false;
|
||||
if (!decoder.decode(cookie.value))
|
||||
return false;
|
||||
if (!decoder.decode(cookie.expiry_time_from_expires_attribute))
|
||||
return false;
|
||||
if (!decoder.decode(cookie.expiry_time_from_max_age_attribute))
|
||||
return false;
|
||||
if (!decoder.decode(cookie.domain))
|
||||
return false;
|
||||
if (!decoder.decode(cookie.path))
|
||||
return false;
|
||||
if (!decoder.decode(cookie.secure_attribute_present))
|
||||
return false;
|
||||
if (!decoder.decode(cookie.http_only_attribute_present))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue