1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-29 14:17:11 +02:00
Commit Graph

2778 Commits

Author SHA1 Message Date
Raymond Hill
72dabcac66
Disallow -abp-... filters if not using #?#
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2435#issuecomment-1367805459
2023-01-01 09:20:32 -05:00
Raymond Hill
3f71659aa8
Work related to keyboard shortcuts for page reload
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/896

Additionally, added the keyboard shortcuts to reload the current
tab to the logger. This changes the prior behavior of reloading
the logger content itself.
2022-12-25 10:34:53 -05:00
Raymond Hill
4157171b7f
Use "constant" property for target hntrie container 2022-12-25 08:54:18 -05:00
Raymond Hill
6a50f41aeb
Internal cell count !== visual cell count
Internal cell count is used to filter the output of the logger. This
commit fixes filtering according to cname alias.
2022-12-24 10:30:25 -05:00
Raymond Hill
b194baa089
Fix visual regressions in logger
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2425
2022-12-24 10:04:31 -05:00
Raymond Hill
d5f9c05d62
Take method= into account when evaluating whether a filter is pure hostname
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2117
2022-12-24 09:49:46 -05:00
Raymond Hill
19f8b30d57
New network filter option: to=[list of domain names]
Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/discussions/2412#discussioncomment-4421741

The new option is `to=` and the value is a list of domain list with
similar syntax as `domain=` option. Entity-based syntax is supported,
and also negated hostname.

The main motivation is to give uBO's static network filtering engine
with an equivalent of DNR's `requestDomains` and `excludedRequestDomains`.

Essentially `to=` is a superset of `denyallow=`, but for now I decided
against deprecating `denyallow=`, which still does not support entity-
based syntax and for which negated domains are not allowed.

This commit also introduces the `from=` option, which is just an alias
for the `domain=` option. The logger will render network filters using
the `from=` version.
2022-12-23 15:52:24 -05:00
Raymond Hill
b6981877ba
Add option to filter by HTTP method in static network filters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2117

Option: `method=`
Value: a list of `|`-separated lowercased method names. Negated
method names are allowed. These are valid methods:

- connect
- delete
- get
- head
- options
- patch
- post
- put

As per DNR's own documentation:
- https://developer.chrome.com/docs/extensions/reference/declarativeNetRequest/#type-RequestMethod

The logger shows the method used for every network request. It's
possible to filter the logger output for most-common methods: `get`,
`head`, `post`.
2022-12-22 13:15:08 -05:00
Raymond Hill
3fe6846da7
Fix case-sensitiveness in :has-text() (regression)
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/zqot4i/is_there_a_way_to_show_only_element_with_specific/j0zl4ck/
2022-12-20 14:34:54 -05:00
Raymond Hill
f78fb513a1
Support generic exception filter for HTML filtering
Related feedback:
- fa5e4b7769 (commitcomment-93202819)
2022-12-15 11:35:03 -05:00
Raymond Hill
a31f74325d
Fix "make lint" errors 2022-12-15 11:20:52 -05:00
Raymond Hill
fa5e4b7769
Fine tune new exceptor code
Related feedback:
- a91781a495 (commitcomment-93128519)

For instance, do not make exceptor widget available for
exceptions from filter lists.
2022-12-15 10:04:59 -05:00
Raymond Hill
a91781a495
Rewrite logger's "exceptor" feature
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1861

The "exceptor" feature has been rewritten, with the following
changes as a result:

- The excepted filters cease to exist when closing the logger
- It's now possible to temporary except network filters

When toggling on/off a temporary exception, filter lists are now
fully reloaded. This simplified managing temporary exceptions, and
made it easy to implement temporary exception for network filters,
but this also means there might be a perceptible delay when
adding/removing temporary exceptions. At this point I consider
this an acceptable side-effect just to bring the ability to easily
create temporary exception for network filters, while this
simplified the existing temporary exception code throughout.
2022-12-14 16:04:45 -05:00
Raymond Hill
d77331f73a
Be sure procedural filterer is present before use
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2407
2022-12-14 08:56:04 -05:00
Raymond Hill
b603e9e81e
Various code review related to extended filtering
Bring latest changes to procedural cosmetic filtering to uBOL.

Fix procedural filtering used in HTML filters.

Standardize quick hash algorithm used throughout to DJB2
(except that initialization step is skipped):
- http://www.cse.yorku.ca/~oz/hash.html#djb2
2022-12-13 10:23:51 -05:00
Raymond Hill
58e60d6d96
Fix various regressions in latest dev build
Related issues:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2404
- https://github.com/uBlockOrigin/uBlock-issues/issues/2400#issuecomment-1346050327
2022-12-12 14:02:57 -05:00
Raymond Hill
0971025b21
Use Blob URLs to reliably inject scriptlets
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/235

Fixed as suggested by <https://github.com/evilpie>, to safely
bypass a page's own CSP.
2022-12-11 10:08:10 -05:00
Raymond Hill
992255e993
Add :remove-attr() and :remove-class() pseudo selector operators
These two new pseudo selectors are _action_ operators, and thus can
only be used at the end of a selector. They both take as argument
a string or regex literal.

For `:remove-class()`, when the argument matches a class name, that
class name is removed.

For `:remove-attr()`, when the argument matches an attribute name,
that attribute is removed.

These operators are meant to replace `+js(remove-attr, ...)` and
`+js(remove-class, ...)`, which from now on are candidate for
deprecation in some future.

Once the next stable release is widespread, filter authors must use
these two new operators instead of their `+js()` counterparts.
2022-12-10 11:18:24 -05:00
Raymond Hill
b0a0a44c64
Revisit validation of combinators in :not() operator
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/z2ttcx/problem_with_custom_filters_in_1452/iza8nkk/
2022-12-09 11:10:39 -05:00
Raymond Hill
78a778922d
Minor code review 2022-12-08 10:14:45 -05:00
Raymond Hill
f1b19d5115
Fix reverse lookup of generic cosmetic filters
Related feedback:
- 26594fb902 (commitcomment-92413254)
2022-12-08 10:07:58 -05:00
Raymond Hill
bbf06ad972
Fix parsing of :matches-attr arguments
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2329#issuecomment-1341349992
2022-12-07 14:15:01 -05:00
Raymond Hill
1bda7e0085
Code review of reworked generic cosmetic filtering code
Related commit:
- 26594fb902
2022-12-07 13:48:44 -05:00
Raymond Hill
26594fb902
Rework generic cosmetic filtering code
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2248
2022-12-07 10:30:09 -05:00
Raymond Hill
76d70102f0
Add pseudo-operator :matches-attr()
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2329

The supported syntax is exactly as per AdGuard's documentation:
- https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#extended-css-matches-attr

Though recommended, the quotes are not mandatory in uBO if
the argument does not cause the parser to fail and if there
are no ambiguities.

Additionally, improved the code to better unquote pseudo-operator
arguments, and to bring it closer to how AdGuard does it as per
documentation. When using quotes, `"` and `\` should be escaped
to preserve these characters in the unquoted version of the
argument.

Additionally, it is now possible to have `:has-text()` match the
empty string by just quoting the empty string:

    ...##foo:has-text("")
2022-12-02 15:43:04 -05:00
Raymond Hill
bedfdff678
No need for arrow function for scoping 2022-11-29 12:01:16 -05:00
Raymond Hill
62601639f6
Detect invalid usage of combinators in :not() pseudoclass
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/z2ttcx/
2022-11-25 10:21:58 -05:00
Raymond Hill
92397baa39
Give more time for viewport to be ready 2022-11-24 11:21:13 -05:00
Raymond Hill
8d80f4788d
Trim content of Import field
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2380
2022-11-23 12:55:20 -05:00
Raymond Hill
bdc7a4c539
Handle potentially invalid CSS selector
Older browser versions may not support valid CSS selector syntax
in newer browser versions.

Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/yzw5pt/
2022-11-21 08:57:55 -05:00
Raymond Hill
eb709335f8
Ensure state of more/less in panel reflect locked/disabled sections
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1059
2022-11-20 13:02:09 -05:00
Raymond Hill
fa216a43e4
Fix typo in string template code
Related commit:
- feaa338678
2022-11-20 10:17:05 -05:00
Raymond Hill
9b3ad0702c
Isolate generic cosmetic filters from specific ones in generated stylesheet
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/yzw5pt/

Some CSS4-based selectors are not supported in older browser versions
and this may cause cosmetic filtering to be wholly broken as a result.

The commit here is to isolate generic cosmetic filters from specific
ones in stylesheets such that unsupported CSS4 selectors in generic
cosmetic filters do not cause wholly breakage of cosmetic filtering
on all sites.
2022-11-20 10:08:28 -05:00
Raymond Hill
44753053c3
Prevent the creation of non-cosmetic extended filters in element picker
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2232
2022-11-19 12:29:10 -05:00
Raymond Hill
4fb4ee1915
Handle negative character group
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2373
2022-11-18 13:37:48 -05:00
Raymond Hill
1c67869c42
Addendum to last commit as per feedback
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2372
2022-11-18 11:23:20 -05:00
Raymond Hill
42a7cfced3
Use already available stringified character code
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2372
2022-11-18 10:10:47 -05:00
Raymond Hill
04b8d495b6
Mind zero quantifier
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2371
2022-11-18 08:52:32 -05:00
Raymond Hill
122b84a6bc
Revert reversion 2022-11-17 13:39:19 -05:00
Raymond Hill
f46e5ef3b5
Further fix tokenization from regex
As per feedback/discussion:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2368
- https://github.com/uBlockOrigin/uBlock-issues/issues/2367
2022-11-17 13:17:32 -05:00
Raymond Hill
105c7f5446
Fix visual of DOM inspector layer in dark theme mode
Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/discussions/2359
2022-11-17 09:25:20 -05:00
Raymond Hill
d51b7e082b
Improve extraction of tokens from regexes
Fixed flawed extraction of tokens with optional sequences, i.e.
when quantifier could be zero.
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2367

Ignore look-around sequences as suggested when normalizing into
tokenizable string.
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2368

Fix regex analyzer throwing with trailing `-` in character
class sequence.
Related issue:
- https://github.com/AdguardTeam/AdguardFilters/pull/134630
2022-11-17 08:53:41 -05:00
Raymond Hill
2cc6835de0
Use placeholders to minimize vertical shifting at page load time
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2361
2022-11-15 09:44:19 -05:00
Raymond Hill
e68537513f
Sort of fix DOM inspector's visual with webpages in dark theme mode
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/discussions/2359#discussioncomment-4126129

Removing `color-scheme` property fixes the issue. Not sure why.
2022-11-14 11:49:59 -05:00
Raymond Hill
4a01affa0e
Undo mistakenly committed changes to the element picker
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2360
2022-11-13 11:07:41 -05:00
Raymond Hill
73c2decdf5
Ensure procedural filters are applied at least once
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/discussions/2261#discussioncomment-4123057

Cosmetic filters will be applied unconditionally at least
once at DOMContentLoaded time.
2022-11-12 11:22:49 -05:00
Raymond Hill
3d24b89078
Fix dom.text() returning textContent 2022-11-12 10:35:40 -05:00
Raymond Hill
feaa338678
Code maintenance: replace uDom.js with dom.js
`uDom` is old and crusty and `dom` is meant as replacement. The
goal of `dom` is to be simpler and mainly just convenience
methods for handling the DOM with vanilla JS -- this is not a
framework.

Additionally, removed keyboard shortcuts pane which was useful
only on very old versions of Firefox.
2022-11-12 09:51:22 -05:00
Raymond Hill
b1a14794bf
Test for unsupported pseudo operators after normalization
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2356
2022-11-10 10:32:22 -05:00
Raymond Hill
20181e9f18
Properly detect unsupported pseudo operators
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/yr8eda/
2022-11-10 09:30:52 -05:00
Raymond Hill
4d4a5f3807
Mind implicit prelude * element in pseudo operators
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2355
2022-11-10 08:47:54 -05:00
Raymond Hill
8a34425ca5
Avoid redundant logger entries for scriptlet injection
Report only when the scriptlets have been successfully injected.
2022-11-06 17:23:06 -05:00
Raymond Hill
49df063191
Try to inject scriptlets at onResponseStarted() time
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2350

As per AdGuard findings, it's possible (though unreliable) to try
to inject scriptlets at webRequest.onResponseStarted time, which
increases scriptlet injection reliability overall when injecting
from multiple entry points.

uBO was already injecting at webNavigation.onCommitted and
main content script time, and adding webRequest.onResponseStarted
as an entry point for scriptlet injection increases reliability
for webpages which executes inline scripts at the top of the DOM.

References:
- https://github.com/AdguardTeam/AdguardBrowserExtension/issues/1029
- https://github.com/AdguardTeam/AdguardBrowserExtension/blob/9ab85be5/Extension/src/background/webrequest.js#L620
2022-11-06 16:54:32 -05:00
Raymond Hill
6574ede152
[mv3] Do not merge rules with errors
Related issue:
- https://github.com/uBlockOrigin/uBOL-issues/issues/10#issuecomment-1304822579
2022-11-06 11:21:02 -05:00
Raymond Hill
36bfa27c30
Rearrange code flow 2022-11-04 11:08:41 -04:00
Raymond Hill
c3d0d574d7
Fix incorrect serialization of pseudo elements
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/ylnvwf/how_to_block_suggestive_keyword_in_reddit_search/iv014wu/
2022-11-04 10:55:10 -04:00
Raymond Hill
42ddac5e3d
Fix unescaped backslashes in selector attribute
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/yjoh9p/
2022-11-02 08:32:54 -04:00
Raymond Hill
4863f3093e
Do not inject scriptlets on navigation events in Firefox
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2343
2022-10-28 11:07:46 -04:00
Raymond Hill
d992824625
Just to be sure no race condition
Related commit:
- d1f8a05d2d
2022-10-27 16:28:55 -04:00
Raymond Hill
d1f8a05d2d
Further ensure scriptlets are actually injected
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/ye6abt/

Possibly because the Opera sidebar window is a special
case, it appears the scriptlets must be injected at a
later time.

Use a global isolated window variable to detect whether
the scriptlets have really be injected, and ultimately
inject them at main content script time when it is found
they haven't been injected at that point.
2022-10-27 15:52:03 -04:00
Raymond Hill
bccd5a0264
Harden scriptlet injections
This commit make it so scriptlet injections will occur
at the earliest possible time on all platform.

This should also fix the case reported at:
- https://www.reddit.com/r/uBlockOrigin/comments/ye6abt/

Which is caused by the fact that there is no webNavigation
events being fired by the browser. In such case, the changes
here will make it so that uBO will detect that the scriptlet
were not injected and will inject them at main content script
injection time.
2022-10-27 14:16:21 -04:00
Raymond Hill
ae5717ea72
Just use the already existing method 2022-10-24 09:30:29 -04:00
Raymond Hill
df7bedbe04
Return punycoded hostname in static extended filtering 2022-10-24 09:08:50 -04:00
Raymond Hill
433adac6ff
[mv3] Add ability to handle entity-based CSS and scriptlet injection filters
This commit adds the ability to inject entity-based plain CSS
filters and also a set of the most commonly used entity-based
scriptlet injection filters.

Since the scripting API is not compatible with entity patterns,
the entity-related content scripts are injected in all documents
and the entity-matching is done by the content script themselves.

Given this, entity-based content scripts are enabled only when
working in the Complete filtering mode, there won't be any
entity-based filters injected in lower modes.

Also, since there is no way to reasonably have access to the
Public Suffix List in the content scripts, the entity-matching
algorithm is an approximation, though I expect false positives
to be rare (time will tell). In the event of such false
positive, simply falling back to Optimal mode will fix the
issue.

The following issues have been fixed at the same time:

Fixed the no-filtering mode related rules having lower priority
then redirect rules, i.e. redirect rules would still be applied
despite disabling all filtering on a site.

Fixed improper detection of changes to the generic-related CSS
content script, potentially causing undue delays when for example
trying to access the popup panel while working in Complete mode.
The scripting MV3 can be quite slow when registering/updating
large content scripts, so uBOL does its best to call the API only
if really needed, but there had been a regression in the recent
builds preventing uBO from properly detecting unchanged content
script parameters.
2022-10-20 15:48:06 -04:00
Raymond Hill
7ec59b09ac
Fix improperly detecting ruleset changes re. dynamic URL filtering
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2330\
2022-10-19 12:12:09 -04:00
Raymond Hill
d027a3f7c4
Fix improperly detecting ruleset changes re. dynamic URL filtering
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2330
2022-10-19 11:37:11 -04:00
Raymond Hill
9879b7d03c
[mv3] Fix overwriting valid DNR rules with invalid entries
This fixes a flaw which has existed since the first version of
uBO Lite.

Related issue:
- https://github.com/uBlockOrigin/uBOL-issues/issues/11

Related commit:
- a559f5f271
2022-10-18 16:12:30 -04:00
Raymond Hill
8aa379ef9e
Fix argument-less :watch-attr() procedural operator
It's valid to have no argument for `:watch-attr()`.
2022-10-18 07:35:47 -04:00
Raymond Hill
44812dd3c0
[mv3] Salvage network rules with entity syntax in domain= option
It's possible to salvage network rule with entity syntax-based
entries in their `domain=` option if there exists at least one
entry which is not entity syntax-based.

For negated entries, these can be unconditionally removed
safely.
2022-10-17 17:41:13 -04:00
Raymond Hill
04119e9cdd
Properly handle unsupported `nth-child(an of selector)
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2284#issuecomment-1280325910
2022-10-17 07:26:51 -04:00
Raymond Hill
d22b4e9f71
[mv3] Revert attempt at fixing rules with entity-based syntax
This will need more careful analysis to properly address this.
2022-10-16 13:20:49 -04:00
Raymond Hill
985ea24e82
[mv3] Add support for redirect= filters
This adds support for `redirect=` filters. As with `removeparam=`
filters, `redirect=` filters can only be enforced when the
default filtering mode is set to Optimal or Complete, since these
filters require broad host permissions to be enforced by the DNR
engine.

`redirect-rule=` filters are not supported since there is no
corresponding DNR syntax.

Additionally, fixed the dropping of whole network filters even though
those filters are still useful despite not being completely
enforceable -- for example a filter with a single (unsupported) domain
using entity syntax in its `domain=` option should not be wholly
dropped when there are other valid domains in the list.
2022-10-16 12:05:24 -04:00
Raymond Hill
30bd6c7bb8
Parse -abp-has as declarative if possible
With the new csstree-based parser, it should now be
safe to parse `-abp-has` as declarative. There are over
a hundred such cosmetic filters in EasyList, and we want
to have these filters declaratively enforced whenever
possible in order to let the browser do the work natively
rather than rely on JS code.
2022-10-14 13:04:47 -04:00
Raymond Hill
873c2e7264
[mv3] Support conditional env_mv3 directive to parser
Related issue:
- https://github.com/uBlockOrigin/uBOL-issues/issues/1
2022-10-11 12:02:33 -04:00
Raymond Hill
8eb28a446c
[mv3] Introduce per-site filtering modes in lieu of per-site toggle switch 2022-10-10 12:28:24 -04:00
Raymond Hill
5659194932
Fix broken :has() operator in HTML filtering
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2228#issuecomment-1273119017
2022-10-10 08:38:40 -04:00
Raymond Hill
3f8e3fe0c6
Fix nth-of-type() not accepting identifier-based arguments
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2284#issuecomment-1271552479
2022-10-07 09:12:45 -04:00
Raymond Hill
93953f9b21
Prepend attribute flags with space
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2310#issuecomment-1269001494
2022-10-06 16:57:03 -04:00
Raymond Hill
9c0d76346b
Fix discarding attribute flags
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2310
2022-10-05 07:08:35 -04:00
Raymond Hill
24273d2c94
Escape attribute values
Related issues:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2284#issuecomment-1265417399
2022-10-04 08:11:31 -04:00
Raymond Hill
e12cd232a0
Procedural operators without parenthesis are invalid
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2305

Bump up selfie/compile version numbers. Related feedback:
- 85adde9f0c (commitcomment-85569639)
2022-10-03 10:47:29 -04:00
Raymond Hill
28aee736a5
[mv3] Add support for removeparam= filter option
Consequently, AdGuard URL Tracking Protection (AUTP) has been
added to the set of available filter lists.

However, removeparam= equivalent DNR rules can only be enforced
when granting uBOL broad permissions. If broad permissions are
not granted, removeparam= equivalent DNR rules are ignored.

Exception removeparam= filters are not supported, and these are
present in AUTP and meant to unbreak some websites which are
known to break as a result of removing query parameters.

This is issue might be mitigated in the future by making the
conversion from filters to DNR rules more complicated but this
can never replace the accuracy of uBO's filtering engine being
able to fully enforce arbitrary exception removeparam= filters.

Also, it is not possible to translate regex-based removeparam=
values to DNR rules, so these are dropped at conversion time.

As with other filters to DNR rules conversion, the converter
coallesce many distinct removeparam= filters into fewer DNR
rules.
2022-09-29 19:51:33 -04:00
Raymond Hill
80e17af9fa
Fix parsing of cosmetic filters with empty-string attribute value
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2303
2022-09-29 12:54:25 -04:00
Raymond Hill
de0f45581c
Fix logging of sub_frame types
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/discussions/2302
2022-09-28 09:58:44 -04:00
Raymond Hill
13927fc203
Rules with excludedResourceTypes must not block main_frame
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2298
2022-09-28 09:37:10 -04:00
Raymond Hill
fe4cfeba2e
Code review re. attribute serializer
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2300

Related commit:
- 7379bafb23
2022-09-28 09:05:04 -04:00
Raymond Hill
7379bafb23
Fix serializing of unquoted attribute values
Related commit:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2300
2022-09-28 08:34:39 -04:00
Raymond Hill
0cd019ec7d
Fix preview of :style()-based cosmetic filters 2022-09-27 09:32:58 -04:00
Raymond Hill
51c2e22c7a
[mv3] Fix procedural operator matches-media()
The failure was caused by the fact that there is no
window.matchMedia() API available in Nodejs. The validation
is now done using cssTree.
2022-09-27 07:46:24 -04:00
Raymond Hill
115f7bb687
Fix operator token-to-ctor map
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2294
2022-09-26 22:27:50 -04:00
Raymond Hill
990ad75ca8
Redirect non-existing operators to a void operator
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2292

This will prevent unexpected oversezealous blocking if ever
this happens again. The internal void operator will ensure
no blocking takes place and issue a note about non-existing
operator to the dev tools console.
2022-09-26 16:46:24 -04:00
Raymond Hill
9a31ac8076
Revert removal of matches-css-related filters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2292

Related commit:
- a71b71e4c8
2022-09-26 12:23:13 -04:00
Raymond Hill
59aa235952
Forbid relative selector at top level
Related commit:
- a71b71e4c8
2022-09-25 08:51:48 -04:00
Raymond Hill
743210f5df
Fix incomplete parsing of nth-of-type() and some other pseudo-classes
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2284

Regression from:
- a71b71e4c8
2022-09-24 17:27:20 -04:00
Raymond Hill
c698a9fcec
Fix overzealous validation of :style() arguments 2022-09-24 12:14:50 -04:00
Raymond Hill
966a157d19
[mv3] Add support for procedural cosmetic filtering 2022-09-24 11:33:04 -04:00
Raymond Hill
a71b71e4c8
New cosmetic filter parser using CSSTree library
The new parser no longer uses the browser DOM to validate
that a cosmetic filter is valid or not, this is now done
through a JS library, CSSTree.

This means filter list authors will have to be more careful
to ensure that a cosmetic filter is really valid, as there is
no more guarantee that a cosmetic filter which works for a
given browser/version will still work properly on another
browser, or different version of the same browser.

This change has become necessary because of many reasons,
one of them being the flakiness of the previous parser as
exposed by many issues lately:

- https://github.com/uBlockOrigin/uBlock-issues/issues/2262
- https://github.com/uBlockOrigin/uBlock-issues/issues/2228

The new parser introduces breaking changes, there was no way
to do otherwise. Some current procedural cosmetic filters will
be shown as invalid with this change. This occurs because the
CSSTree library gets confused with some syntax which was
previously allowed by the previous parser because it was more
permissive.

Mainly the issue is with the arguments passed to some procedural
cosmetic filters, and these issues can be solved as follow:

Use quotes around the argument. You can use either single or
double-quotes, whichever is most convenient. If your argument
contains a single quote, use double-quotes, and vice versa.

Additionally, try to escape a quote inside an argument using
backslash. THis may work, but if not, use quotes around the
argument.

When the parser encounter quotes around an argument, it will
discard them before trying to process the argument, same with
escaped quotes inside the argument. Examples:

Breakage:

    ...##^script:has-text(toscr')

Fix:

    ...##^script:has-text(toscr\')

Breakage:

    ...##:xpath(//*[contains(text(),"VPN")]):upward(2)

Fix:

    ...##:xpath('//*[contains(text(),"VPN")]'):upward(2)

There are not many filters which break in the default set of
filter lists, so this should be workable for default lists.

Unfortunately those fixes will break the filter for previous
versions of uBO since these to not deal with quoted argument.
In such case, it may be necessary to keep the previous filter,
which will be discarded as broken on newer version of uBO.

THis was a necessary change as the old parser was becoming
more and more flaky after being constantly patched for new
cases arising, The new parser should be far more robust and
stay robist through expanding procedural cosmetic filter
syntax.

Additionally, in the MV3 version, filters are pre-compiled
using a Nodejs script, i.e. outside the browser, so validating
cosmetic filters using a live DOM no longer made sense.

This new parser will have to be tested throughly before stable
release.
2022-09-23 16:03:13 -04:00
Raymond Hill
4bd02c0fb6
[mv3] Inject specific cosmetic filters through scriptlet injection
This solves the following remaining issues regarding specific cosmetic
filtering:
- High rate of false positives in last build
- High number of generated content css files in the package
2022-09-19 08:55:45 -04:00
Raymond Hill
35f4bdd113
Add ext_ubol to tokens recognized by the preparser
`ext_ubol` will evaluate to false in uBO, and true in uBO Lite.

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2268
2022-09-18 11:06:07 -04:00
Raymond Hill
5ddd3aaac6
[mv3] More work toward improving declarative css/js injection 2022-09-18 09:31:44 -04:00