+ }
+ else // Process the filter options.
+ {
+ // Split any filter options from the end of the string.
+ QStringList splitEntryStringList = filterListString.split(QLatin1Char('$'));
+
+ // Store the entry without the filter options as the filter list string.
+ filterListString = splitEntryStringList[0];
+
+ // Create a popup only filter option tracker.
+ bool popupOnlyFilterOption = false;
+
+ // Process the filter options if they exist.
+ if (splitEntryStringList.size() > 1)
+ {
+ // Store the filter options.
+ entryStructPointer->filterOptions = splitEntryStringList[1];
+
+ // Split the filter options.
+ QStringList filterOptionsList = splitEntryStringList[1].split(QLatin1Char(','));
+
+ // Check if the entry has a single popup filter option as Qt WebEngine doesn't know how to process them.
+ if ((filterOptionsList.size() == 1) && (filterOptionsList[0] == QLatin1String("popup"))) // This entry has a single popup filter option.
+ {
+ // Set the popup only filter option flag.
+ popupOnlyFilterOption = true;
+ }
+ else // This entry has filter options besides popup.
+ {
+ // Initialize an override struct.
+ OverrideStruct overrideStruct;
+
+ // Populate the filter options entries.
+ foreach (QString filterOption, filterOptionsList)
+ {
+ // Populate the third-party options.
+ if (filterOption == QLatin1String("third-party")) entryStructPointer->thirdParty = FilterOptionEnum::Disposition::Apply;
+ if (filterOption == QLatin1String("~third-party")) entryStructPointer->thirdParty = FilterOptionEnum::Disposition::Override;
+
+ // Populate the filter options.
+ if (filterOption == QLatin1String("document"))
+ {
+ // Populate the main frame option.
+ entryStructPointer->mainFrame = FilterOptionEnum::Disposition::Apply;
+
+ // Set the filter options flag.
+ entryStructPointer->hasFilterOptions = true;
+ }
+
+ if (filterOption == QLatin1String("font"))
+ {
+ // Populate the font option.
+ entryStructPointer->font = FilterOptionEnum::Disposition::Apply;
+
+ // Set the filter options flag.
+ entryStructPointer->hasFilterOptions = true;
+ }
+
+ if (filterOption == QLatin1String("image"))
+ {
+ // Populate the image option.
+ entryStructPointer->image = FilterOptionEnum::Disposition::Apply;
+
+ // Set the filter options flag.
+ entryStructPointer->hasFilterOptions = true;
+ }
+
+ if (filterOption == QLatin1String("media"))
+ {
+ // Populate the media option.
+ entryStructPointer->media = FilterOptionEnum::Disposition::Apply;
+
+ // Set the filter options flag.
+ entryStructPointer->hasFilterOptions = true;
+ }
+
+ if (filterOption == QLatin1String("object"))
+ {
+ // Populate the object option.
+ entryStructPointer->object = FilterOptionEnum::Disposition::Apply;
+
+ // Set the filter options flag.
+ entryStructPointer->hasFilterOptions = true;
+ }
+
+ if (filterOption == QLatin1String("other"))
+ {
+ // Populate the other option.
+ entryStructPointer->other = FilterOptionEnum::Disposition::Apply;
+
+ // Set the filter options flag.
+ entryStructPointer->hasFilterOptions = true;
+ }
+
+ if (filterOption == QLatin1String("ping"))
+ {
+ // Populate the ping option.
+ entryStructPointer->ping = FilterOptionEnum::Disposition::Apply;
+
+ // Set the filter options flag.
+ entryStructPointer->hasFilterOptions = true;
+ }
+
+ if (filterOption == QLatin1String("script"))
+ {
+ // Populate the script option.
+ entryStructPointer->script = FilterOptionEnum::Disposition::Apply;
+
+ // Set the filter options flag.
+ entryStructPointer->hasFilterOptions = true;
+ }
+
+ if (filterOption == QLatin1String("stylesheet"))
+ {
+ // Populate the script option.
+ entryStructPointer->styleSheet = FilterOptionEnum::Disposition::Apply;
+
+ // Set the filter options flag.
+ entryStructPointer->hasFilterOptions = true;
+ }
+
+ if (filterOption == QLatin1String("subdocument"))
+ {
+ // Populate the sub resource option.
+ entryStructPointer->subFrame = FilterOptionEnum::Disposition::Apply;
+
+ // Set the filter options flag.
+ entryStructPointer->hasFilterOptions = true;
+ }
+
+ if (filterOption == QLatin1String("xmlhttprequest"))
+ {
+ //Populate the XML HTTP request option.
+ entryStructPointer->xmlHttpRequest = FilterOptionEnum::Disposition::Apply;
+
+ // Set the filter options flag.
+ entryStructPointer->hasFilterOptions = true;
+ }
+
+ // Populate the override struct.
+ if (filterOption == QLatin1String("~document"))
+ {
+ // Populate the override struct.
+ overrideStruct.hasOverride = true;
+ overrideStruct.mainFrame = true;
+ }
+
+ if (filterOption == QLatin1String("~font"))
+ {
+ // Populate the override struct.
+ overrideStruct.hasOverride = true;
+ overrideStruct.font = true;
+ }
+
+ if (filterOption == QLatin1String("~image"))
+ {
+ // Populate the override struct.
+ overrideStruct.hasOverride = true;
+ overrideStruct.image = true;
+ }
+
+ if (filterOption == QLatin1String("~media"))
+ {
+ // Populate the override struct.
+ overrideStruct.hasOverride = true;
+ overrideStruct.media = true;
+ }
+
+ if (filterOption == QLatin1String("~object"))
+ {
+ // Populate the override struct.
+ overrideStruct.hasOverride = true;
+ overrideStruct.object = true;
+ }
+
+ if (filterOption == QLatin1String("~other"))
+ {
+ // Populate the override struct.
+ overrideStruct.hasOverride = true;
+ overrideStruct.other = true;
+ }
+
+ if (filterOption == QLatin1String("~ping"))
+ {
+ // Populate the override struct.
+ overrideStruct.hasOverride = true;
+ overrideStruct.ping = true;
+ }
+
+ if (filterOption == QLatin1String("~script"))
+ {
+ // Populate the override struct.
+ overrideStruct.hasOverride = true;
+ overrideStruct.script = true;
+ }
+
+ if (filterOption == QLatin1String("~stylesheet"))
+ {
+ // Populate the override struct.
+ overrideStruct.hasOverride = true;
+ overrideStruct.styleSheet = true;
+ }
+
+ if (filterOption == QLatin1String("~subdocument"))
+ {
+ // Populate the override struct.
+ overrideStruct.hasOverride = true;
+ overrideStruct.subFrame = true;
+ }
+
+ if (filterOption == QLatin1String("~xmlhttprequest"))
+ {
+ // Populate the override struct.
+ overrideStruct.hasOverride = true;
+ overrideStruct.xmlHttpRequest = true;
+ }
+ }
+
+ // Apply the overrides.
+ if (overrideStruct.hasOverride)
+ {
+ // Font.
+ if (overrideStruct.font)
+ entryStructPointer->font = FilterOptionEnum::Disposition::Override;
+ else
+ entryStructPointer->font = FilterOptionEnum::Disposition::Apply;
+
+ // Image.
+ if (overrideStruct.image)
+ entryStructPointer->image = FilterOptionEnum::Disposition::Override;
+ else
+ entryStructPointer->image = FilterOptionEnum::Disposition::Apply;
+
+ // Main Frame (document).
+ if (overrideStruct.mainFrame)
+ entryStructPointer->mainFrame = FilterOptionEnum::Disposition::Override;
+ else
+ entryStructPointer->mainFrame = FilterOptionEnum::Disposition::Apply;
+
+ // Media.
+ if (overrideStruct.media)
+ entryStructPointer->media = FilterOptionEnum::Disposition::Override;
+ else
+ entryStructPointer->media = FilterOptionEnum::Disposition::Apply;
+
+ // Object.
+ if (overrideStruct.object)
+ entryStructPointer->object = FilterOptionEnum::Disposition::Override;
+ else
+ entryStructPointer->object = FilterOptionEnum::Disposition::Apply;
+
+ // Other.
+ if (overrideStruct.other)
+ entryStructPointer->other = FilterOptionEnum::Disposition::Override;
+ else
+ entryStructPointer->other = FilterOptionEnum::Disposition::Apply;
+
+ // Ping.
+ if (overrideStruct.ping)
+ entryStructPointer->ping = FilterOptionEnum::Disposition::Override;
+ else
+ entryStructPointer->ping = FilterOptionEnum::Disposition::Apply;
+
+ // Script.
+ if (overrideStruct.script)
+ entryStructPointer->script = FilterOptionEnum::Disposition::Override;
+ else
+ entryStructPointer->script = FilterOptionEnum::Disposition::Apply;
+
+ // Style Sheet.
+ if (overrideStruct.styleSheet)
+ entryStructPointer->styleSheet = FilterOptionEnum::Disposition::Override;
+ else
+ entryStructPointer->styleSheet = FilterOptionEnum::Disposition::Apply;
+
+ // Sub Resource.
+ if (overrideStruct.subFrame)
+ entryStructPointer->subFrame = FilterOptionEnum::Disposition::Override;
+ else
+ entryStructPointer->subFrame = FilterOptionEnum::Disposition::Apply;
+
+ // XML HTTP Request.
+ if (overrideStruct.xmlHttpRequest)
+ entryStructPointer->xmlHttpRequest = FilterOptionEnum::Disposition::Override;
+ else
+ entryStructPointer->xmlHttpRequest = FilterOptionEnum::Disposition::Apply;
+ }
+ }
+ }
+
+ // Drop entries that only have a single popup filter option as Qt WebEngine doesn't know how to process them.
+ if (popupOnlyFilterOption) // This entry has a single popup filter option.
+ {
+ // Do nothing.
+
+ // Log the dropping of the line.
+ //qDebug().noquote().nospace() << entryStructPointer->originalEntry << " NOT added from " << filterListFileName << " (single popup filter option).";
+ }
+ else if (filterListString.startsWith(QLatin1String("@@"))) // Process an allow list entry.
+ {
+ // Remove the initial `@@`.
+ filterListString.remove(0, 2);