Skip to content

Unexpected behaviour when using a * as TLD in snippet filters

Environment

  • OS version: Windows 10
  • Browser version: Chrome 81.0.4000.2 (Official Build) canary (64-bit)
  • Extension version: ABP 3.7 (stable)
  • Last working version: Not sure

How to reproduce

  1. Open Advanced tab in desktop settings page
  2. Add the filter example.*#$#abort-on-property-read matchMedia to custom filters
  3. Refresh the page and go to the advanced tab
  4. Add the missing space (before parameter) back

Observed behavior

  1. After 2) two filters are added instead of one, the original filter plus another filter without the space before the parameter (see first screenshot)
  2. After 3) There is one filter, not the original one added, but one without the space before parameter (see second screenshot)
  3. After 4) the filter disappears

Expected behavior

Filter is either added exactly as it is (only once), or rejected

Further information

I'm not sure if * is supported as TLD in snippet filters, but they seem not.

Screenshots:

image

image

Integration notes

Element hiding filters, element hiding emulation filters, element hiding exceptions, and snippet filters may now contain a * in the domains part of the filter text as specified in the proposal in https://gitlab.com/eyeo/adblockplus/adblockpluscore/issues/111#note_269757932.

In order to address the issue from the UI perspective, eyeo/adblockplus/adblockpluschrome> must examine the domains property of the ActiveFilter object to look for any invalid domains using the new isValidHostname() function from lib/url.js and report the error/warning to the UI as appropriate. For example, if the change is made to the parseFilter() function in lib/filterConfiguration.js, the final code might look something like this:

let filter = Filter.fromText(text);
if (filter instanceof InvalidFilter)
{
  error = new FilterError("invalid_filter", filter.reason);
}
else if (filter instanceof ActiveFilter)
{
  for (let [domain] of filter.domains)
  {
    if (!isValidHostname(domain))
    {
      error = new FilterError("invalid_domain", domain);
      break;
    }
  }
}

return [filter, error];

/label bug

Edited by Manish Jethani