+ }
+ else // Process the filter options.
+ {
+ // Get the index of the last dollar sign.
+ int indexOfLastDollarSign = filterListString.lastIndexOf(QLatin1Char('$'));
+
+ // Process the filter options if they exist.
+ if (indexOfLastDollarSign > -1)
+ {
+ // Get the filter options.
+ entryStructPointer->originalFilterOptions = filterListString.section(QLatin1Char('$'), -1);
+
+ // Store the entry without the filter options as the filter list string.
+ filterListString.truncate(indexOfLastDollarSign);
+
+ // Split the filter options.
+ QStringList originalFilterOptionsList = entryStructPointer->originalFilterOptions.split(QLatin1Char(','));
+
+ // Create an applied filter options list.
+ QStringList appliedFilterOptionsList;
+
+ // Populate the applied filter options list.
+ foreach (QString filterOption, originalFilterOptionsList)
+ {
+ // Only add filter options that are handled by Privacy Browser.
+ if (!(filterOption.startsWith(QLatin1String("csp=")) ||
+ filterOption.startsWith(QLatin1String("method=")) ||
+ filterOption.startsWith(QLatin1String("redirect=")) ||
+ filterOption.startsWith(QLatin1String("rewrite="))))
+ appliedFilterOptionsList.append(filterOption);
+ }
+
+ // Store the applied filter options list.
+ entryStructPointer->appliedFilterOptionsList = appliedFilterOptionsList;
+
+ // Initialize an override struct.
+ OverrideStruct overrideStruct;
+
+ // Populate the filter options entries.
+ foreach (QString filterOption, appliedFilterOptionsList)
+ {
+ // Parse the filter options.
+ if (filterOption.startsWith(QLatin1String("domain="))) // Domain.
+ {
+ // Remove `domain=` from the filter option.
+ filterOption.remove(0, 7);
+
+ // Store the domain list.
+ entryStructPointer->domainList = filterOption.split(QLatin1Char('|'));
+
+ // Set the disposition.
+ if (entryStructPointer->domainList[0].startsWith(QLatin1Char('~'))) // Override domains.
+ {
+ // Populate the domain filter disposition.
+ entryStructPointer->domain = FilterOptionEnum::Disposition::Override;
+
+ // Remove the initial `~` from each domain.
+ entryStructPointer->domainList.replaceInStrings(QLatin1String("~"), QLatin1String(""));
+ }
+ else // Standard domains.
+ {
+ // Populate the domain filter disposition.
+ entryStructPointer->domain = FilterOptionEnum::Disposition::Apply;
+ }
+ }
+ else if (filterOption == QLatin1String("third-party")) // Third-party.
+ {
+ // Populate the third-party filter disposition.
+ entryStructPointer->thirdParty = FilterOptionEnum::Disposition::Apply;
+ }
+ else if (filterOption == QLatin1String("~third-party")) // Third-party override.
+ {
+ // Populate the third-party filter disposition.
+ entryStructPointer->thirdParty = FilterOptionEnum::Disposition::Override;
+ }
+ else if ((filterOption == QLatin1String("document")) || (filterOption == QLatin1String("popup"))) // Document (and popup).
+ {
+ // Populate the main frame disposition.
+ entryStructPointer->mainFrame = FilterOptionEnum::Disposition::Apply;
+
+ // Set the has request options flag.
+ entryStructPointer->hasRequestOptions = true;
+ }
+ else if (filterOption == QLatin1String("font")) // Font.
+ {
+ // Populate the font disposition.
+ entryStructPointer->font = FilterOptionEnum::Disposition::Apply;
+
+ // Set the has request options flag.
+ entryStructPointer->hasRequestOptions = true;
+ }
+ else if (filterOption == QLatin1String("image")) // Image.
+ {
+ // Populate the image disposition.
+ entryStructPointer->image = FilterOptionEnum::Disposition::Apply;
+
+ // Set the has request options flag.
+ entryStructPointer->hasRequestOptions = true;
+ }
+ else if (filterOption == QLatin1String("media")) // Media.
+ {
+ // Populate the media disposition.
+ entryStructPointer->media = FilterOptionEnum::Disposition::Apply;
+
+ // Set the has request options flag.
+ entryStructPointer->hasRequestOptions = true;
+ }
+ else if (filterOption == QLatin1String("object")) // Object.
+ {
+ // Populate the object disposition.
+ entryStructPointer->object = FilterOptionEnum::Disposition::Apply;
+
+ // Set the has request options flag.
+ entryStructPointer->hasRequestOptions = true;
+ }
+ else if ((filterOption == QLatin1String("other")) || (filterOption == QLatin1String("webrtc")) || (filterOption == QLatin1String("websocket"))) // Other.
+ { // `websocket` will get its own section in Qt6.
+ // Populate the other disposition.
+ entryStructPointer->other = FilterOptionEnum::Disposition::Apply;
+
+ // Set the has request options flag.
+ entryStructPointer->hasRequestOptions = true;
+ }
+ else if (filterOption == QLatin1String("ping")) // Ping.
+ {
+ // Populate the ping disposition.
+ entryStructPointer->ping = FilterOptionEnum::Disposition::Apply;
+
+ // Set the has request options flag.
+ entryStructPointer->hasRequestOptions = true;
+ }
+ else if (filterOption == QLatin1String("script")) // Script.
+ {
+ // Populate the script disposition.
+ entryStructPointer->script = FilterOptionEnum::Disposition::Apply;
+
+ // Set the has request options flag.
+ entryStructPointer->hasRequestOptions = true;
+ }
+ else if (filterOption == QLatin1String("stylesheet")) // Style sheet.
+ {
+ // Populate the script disposition.
+ entryStructPointer->styleSheet = FilterOptionEnum::Disposition::Apply;
+
+ // Set the has request options flag.
+ entryStructPointer->hasRequestOptions = true;
+ }
+ else if (filterOption == QLatin1String("subdocument")) // Sub document.
+ {
+ // Populate the sub resource disposition.
+ entryStructPointer->subFrame = FilterOptionEnum::Disposition::Apply;
+
+ // Set the has request options flag.
+ entryStructPointer->hasRequestOptions = true;
+ }
+ else if (filterOption == QLatin1String("xmlhttprequest")) // XML HTTP request.
+ {
+ //Populate the XML HTTP request disposition.
+ entryStructPointer->xmlHttpRequest = FilterOptionEnum::Disposition::Apply;
+
+ // Set the has request options flag.
+ entryStructPointer->hasRequestOptions = true;
+ }
+ else if (filterOption == QLatin1String("~document")) // Document override.
+ {
+ // Populate the override struct.
+ overrideStruct.hasOverride = true;
+ overrideStruct.mainFrame = true;
+ }
+ else if (filterOption == QLatin1String("~font")) // Font override.
+ {
+ // Populate the override struct.
+ overrideStruct.hasOverride = true;
+ overrideStruct.font = true;
+ }
+ else if (filterOption == QLatin1String("~image")) // Image override.
+ {
+ // Populate the override struct.
+ overrideStruct.hasOverride = true;
+ overrideStruct.image = true;
+ }
+ else if (filterOption == QLatin1String("~media")) // Media override.
+ {
+ // Populate the override struct.
+ overrideStruct.hasOverride = true;
+ overrideStruct.media = true;
+ }
+ else if (filterOption == QLatin1String("~object")) // Object override.
+ {
+ // Populate the override struct.
+ overrideStruct.hasOverride = true;
+ overrideStruct.object = true;
+ }
+ else if ((filterOption == QLatin1String("~other")) || (filterOption == QLatin1String("~webrtc")) || (filterOption == QLatin1String("~websocket"))) // Other override.
+ { // `websocket` will get its own section in Qt6.
+ // Populate the override struct.
+ overrideStruct.hasOverride = true;
+ overrideStruct.other = true;
+ }
+ else if (filterOption == QLatin1String("~ping")) // Ping override.
+ {
+ // Populate the override struct.
+ overrideStruct.hasOverride = true;
+ overrideStruct.ping = true;
+ }
+ else if (filterOption == QLatin1String("~script")) // Script override.
+ {
+ // Populate the override struct.
+ overrideStruct.hasOverride = true;
+ overrideStruct.script = true;
+ }
+ else if (filterOption == QLatin1String("~stylesheet")) // Style sheet override.
+ {
+ // Populate the override struct.
+ overrideStruct.hasOverride = true;
+ overrideStruct.styleSheet = true;
+ }
+ else if (filterOption == QLatin1String("~subdocument")) // Sub document override.
+ {
+ // Populate the override struct.
+ overrideStruct.hasOverride = true;
+ overrideStruct.subFrame = true;
+ }
+ else if (filterOption == QLatin1String("~xmlhttprequest")) // XML HTTP request override.
+ {
+ // Populate the override struct.
+ overrideStruct.hasOverride = true;
+ overrideStruct.xmlHttpRequest = true;
+ }
+ }
+
+ // Apply the overrides.
+ if (overrideStruct.hasOverride)
+ {
+ // Set the has request options flag.
+ entryStructPointer->hasRequestOptions = true;
+
+ // 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;