1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:54:58 +00:00

Browser+Ladybird+LibWeb: Prevent infinite growth of content filters

We never clear content filters on either end of the Browser-WebContent
IPC connection. So when the filters change, we re-append all filters to
the Vector holding them. This incidentally makes it impossible to remove
a filter.

Change both sides to clear their filter lists when receiving a new set
of filters.
This commit is contained in:
Timothy Flynn 2023-04-21 07:36:40 -04:00 committed by Andreas Kling
parent b0ffb15e13
commit 76ae60da15
5 changed files with 33 additions and 14 deletions

View file

@ -50,6 +50,9 @@ static ErrorOr<void> load_content_filters()
auto file = TRY(Core::File::open(DeprecatedString::formatted("{}/BrowserContentFilters.txt", Core::StandardPaths::config_directory()), Core::File::OpenMode::Read));
auto ad_filter_list = TRY(Core::BufferedFile::create(move(file)));
auto buffer = TRY(ByteBuffer::create_uninitialized(4096));
Browser::g_content_filters.clear_with_capacity();
while (TRY(ad_filter_list->can_read_line())) {
auto line = TRY(ad_filter_list->read_line(buffer));
if (!line.is_empty())