Skip to content

Procedural filters may select non-Element nodes #3720

@antonok-edm

Description

@antonok-edm

Prerequisites

  • I verified that this is not a filter list issue. Report any issues with filter lists or broken website functionality in the uAssets issue tracker.
  • This is NOT a YouTube, Facebook or Twitch report. These sites MUST be reported by clicking their respective links.
  • This is not a support issue or a question. For support, questions, or help, visit /r/uBlockOrigin.
  • I performed a cursory search of the issue tracker to avoid opening a duplicate issue.
  • The issue is not present after disabling uBO in the browser.
  • I checked the documentation to understand that the issue I am reporting is not normal behavior.

I tried to reproduce the issue when...

  • uBO is the only extension.
  • uBO uses default lists and settings.
  • using a new, unmodified browser profile.

Description

In certain cases, uBlock Origin may attempt to execute a procedural filter on a Node that is not an Element, which could throw an error like the following:

Uncaught TypeError: node.getAttributeNames is not a function
 at PSelectorMatchesAttrTask.transpose

In such cases, the filter will no longer work correctly even if it should technically still match elements on the page.

A specific URL where the issue occurs.

https://example.com

Steps to Reproduce

  1. Add the following filter to My filters:
    example.com##:matches-attr(href)
    
    (yes, procedural filters should ideally be more specific, but this is just for demonstration purposes)
  2. Visit https://example.com
  3. Check the console

Expected behavior

No errors should be thrown, and the More information... link should be hidden.

Actual behavior

There is an error in the console due to the procedural filter operating on the document node, and the link is still visible.

uBO version

1.65.0

Browser name and version

Firefox 140.0.4, Chromium 139.0.7258.32

Operating System and version

Arch Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions