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

2586 Commits

Author SHA1 Message Date
Raymond Hill
a6cd954a2a
Fix handling of negated types in all filter option
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1730

Related commit:
- 8f98622374
2021-09-25 12:36:33 -04:00
Raymond Hill
1130746a9b
Fix regression with important filter option
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1732

The regression affect filter with the `important` option when
the following conditions were fulfilled:

- The filter pattern is pure hostname
- The filter has not one of the following options:
  - domain
  - denyallow
  - header
  - strict1p, strict3p
  - csp
  - removeparam
- There is a matching exception filter

Related commit:
- a2a8ef7e85

A related mocha test has been added in order to detect this
specific regression in the future through `make test`.
2021-09-24 11:09:32 -04:00
Raymond Hill
8f98622374
Refactor implementation of ~[type] filter options
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1730

A new filter unit, FilterNotType, is introduced to enforce
negated filter type options.

Before this commit, there was no actual negated types in the
static network filtering engine, as a negated type was internally
converted to non-negated types at compile time. As a result,
the logger would never output a matching filter with its original
negated type options.

This commit no longer causes an internal conversion to take place
at compile time, but explicitly enforce negated types at match time,
and as a result the logger will from now on output matching filter
with their original negated type options.
2021-09-23 09:38:27 -04:00
Raymond Hill
f49c4e254b
Add advanced setting to default modify webext flavor
Name: modifyWebextFlavor

Value: A list of space-separated tokens to be added/removed from the
computed default webext flavor.

The primary purpose is to give filter list authors the ability to
test mobile flavor on desktop computers. Though mobile versions of
web pages can be emulated using browser dev tools, it's not
possible to do so for uBO itself.

By using `+mobile` as a value for this setting will force uBO
to act as if it's being executed on a mobile device.

Important: this setting is best used in a dedicated browser
profile, as this affects how filter lists are compiled. So best
to set it in a new browser profile, then force all filter lists
to be recompiled, and use the profile in the future when there
is a need to test the specific webext flavor.
2021-09-22 09:37:21 -04:00
Raymond Hill
33a18c3a1e
Convert fingerprint2.js scriptlet into a redirectable resource
As per internal discussion with volunteer filter list
maintainers.
2021-09-18 10:55:22 -04:00
Raymond Hill
4100761863
Keep ability to prevent local IP address leaks for mobile version
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1723

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1723#issuecomment-919913361
2021-09-15 08:28:10 -04:00
Raymond Hill
831cf478da
Revert "Remove now obsolete webrtc-related setting"
This reverts commit af41aadab7.
2021-09-15 07:40:32 -04:00
Raymond Hill
af41aadab7
Remove now obsolete webrtc-related setting
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1723

The leaking of local IP addresses is no longer an issue
in modern browsers.
2021-09-14 10:04:35 -04:00
Raymond Hill
d930504e3e
Better lookup all elements under mouse cursor in element picker
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/pefaov/elementpickerzapper_often_misses_images/hcnycbx/?context=3
2021-09-13 10:39:17 -04:00
Raymond Hill
a3a66d0e31
Avoid parsing query parameters with URLSearchParams
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1717
2021-09-12 12:17:46 -04:00
Eli Grey
6e6697fab6
Fix typo in comment about buffer expiry
The code below the comment specifies 30 seconds, while the comment says 60 seconds. This PR fixes that typo to make the comment indicate 30 seconds.
2021-08-26 17:03:39 -07:00
Raymond Hill
46eb3801ec
Revert "Inject scriptlets at webNavigation.onCommitted time in Firefox"
This reverts commit 7ee9c21b37.

Potentially related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1696
2021-08-26 18:36:36 -04:00
Raymond Hill
7ee9c21b37
Inject scriptlets at webNavigation.onCommitted time in Firefox
Just as is the case with Chromium.

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1694
2021-08-25 09:24:10 -04:00
Raymond Hill
a2d8545382
Forbid instances of /* in :style() operator
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1693
2021-08-25 07:43:26 -04:00
Raymond Hill
6dcd5df991
Take into account simple selectors present in array of selectors
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1692
2021-08-24 12:29:48 -04:00
Raymond Hill
f0b46bde4f
Mitigate generic cosmetic filters erroneously targeting html/body
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1692

The ids/classes from html/body elements will leave out
looking up lowly generic cosmetic filters made of a single
identifier.

This does not absolutely guarantee that html/body elements
will never be targeted, but it should greatly mitigate the
probability that this erroneously happens.
2021-08-24 10:03:25 -04:00
Manish Jethani
925c01dc14
Fix ESLint globals error in biditrie.js (#3850) 2021-08-23 11:10:49 -04:00
Manish Jethani
d959c7aabe
Remove globals.js (#3849) 2021-08-23 10:54:16 -04:00
Manish Jethani
d13294dd39
Remove globals usage from background.js (#3848) 2021-08-23 10:28:44 -04:00
Manish Jethani
724a946c79
Remove globals usage from start.js (#3847) 2021-08-23 10:16:02 -04:00
Manish Jethani
9761b02c79
Convert publicsuffixlist.js into an ES module (#3846) 2021-08-23 09:42:27 -04:00
Raymond Hill
ba83c21354
Fix trie instance iterator 2021-08-22 13:06:05 -04:00
Manish Jethani
9ddbb293c0
Convert punycode.js into an ES module (#3845) 2021-08-22 12:03:59 -04:00
Manish Jethani
1bde1e5ecb
Convert regex.js into an ES module (#3844) 2021-08-22 08:25:06 -04:00
Raymond Hill
9d4006f2c3
Include query string when evaluating matches-path()
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1690#issuecomment-903133439
2021-08-21 11:50:46 -04:00
Raymond Hill
c0c70e2987
Fix normalization of matches-path operator
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1690
2021-08-21 10:20:43 -04:00
Raymond Hill
9dece3bd30
Add new procedural cosmetic operator: :matches-path(...)
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1690

New procedural operator: `:matches-path(...)`

Description: this is a all-or-nothing passthrough operator, which
on/off behavior is dictated by whether the argument match the
path of the current location. The argument can be either plain
text to be found at any position in the path, or a literal regex
against which the path is tested.

Whereas cosmetic filters can be made specific to whole domain,
the new `:matches-path()` operator allows to further narrow
the specificity according to the path of the current document
lcoation.

Typically this procedural operator is used as first operator in
a procedural cosmetic filter, so as to ensure that no further
matching work is performed should there be no match against the
current path of the current document location.

Example of usage:

    example.com##:matches-path(/shop) p

Will hide all `p` elements when visiting `https://example.com/shop/stuff`,
but not when visiting `https://example.com/` or any other page
on `example.com` which has no instance of `/shop` in the path part
of the URL.
2021-08-21 09:41:48 -04:00
Manish Jethani
5d2c295600
Remove globals usage from hntrie.js (#3842) 2021-08-21 07:33:53 -04:00
Manish Jethani
ab13903019
Remove globals usage from static-net-filtering.js (#3841) 2021-08-20 07:54:05 -04:00
Raymond Hill
19160f9018
Drop requestIdleCallback from globals
Related discussion:
- https://github.com/gorhill/uBlock/pull/3839

`requestIdleCallback` can be assumed always present on
browser-related platforms.
2021-08-19 07:31:27 -04:00
Raymond Hill
68675ed1cd
Remove pointless dependency on location
Related discussion:
- https://github.com/gorhill/uBlock/pull/3839#discussion_r691502793
2021-08-19 07:23:53 -04:00
Manish Jethani
b19393d8dc
Add tasks.js module (#3839) 2021-08-19 07:19:20 -04:00
Raymond Hill
9ceef65f9a
Fix regression with reporting "important" in logger
Related feedback:
- a2a8ef7e85 (commitcomment-54972030)
2021-08-17 07:32:54 -04:00
Raymond Hill
a33f70cf20
Provide compiler/selfie versions for snfe
So as to allow nodejs usage to better deal with
out of date serialization/compilation.

Additionally, use FilterImportant() only when a
"block-important" filter is stored in the "block" realm.
2021-08-16 12:15:30 -04:00
Raymond Hill
a2a8ef7e85
Avoid matching the block-important realm unconditionally
When matching a network request in the static network filtering
engine ("snfe"), these are the possible outcomes, from most
to least likely:

- No block
- Block
- Unblock ("exception" filter overriding the block)
- Block-important ("important" filter override the unblock)

Hence why the matching in the snfe always check for a match in
the "block" realm, and the "unblock" realm would be checked
if and only if there was a match in the "block" realm.

However the "block-important" realm was always matched against
first, and when a match in that realm was found, there would
be no need to check in other realms since nothing can override
the "important" option. The problem with this approach though
is that matches in the "block-important" realm are most
unlikely, which means pointless work being done for vast
majority of network requests.

This commit makes it so that the "block-important" realm is
matched against ONLY when there is a matched "unblock" filter.
The result is a measurable improvement in the snfe-related
benchmarks (though given the numbers involved, end users won't
perceive a difference).

Somewhat related discussion which was the motivation to look
more into this:

https://github.com/cliqz-oss/adblocker/discussions/2170#discussioncomment-1168125
2021-08-16 10:58:04 -04:00
Raymond Hill
c6fb70b1f0
Refactor hntrie to avoid the need for boundary cells
Whereas before the string segment was encoded as:

LL OOOOOOOOOOOO

where L are the upper 8 bits and used to encode the length
of the segment, and O are the lower 24 bits and used to
encode the offset of the string data in the character
buffer, the new code encode as follow:

OOOOOOOOOOOO LL

And furthermore the most significant bit of the length
LL is now used to mark whether the current string segment
is a label boundary.

This means a cell can't reference a segment longer then
127 characters. To work around this limitation for when a
segment is longer than 127 characters (a rare occurrence),
the algorithm will simply split the segment into multiple
adjacent cells.

As a result, there is no longer a need to encode
"boundariness" into special cells, which simplifies
both the storing and matching algorithms.

Additionally, added minimal documentation for the NPM
package on how to import and use HNTrieContainer as a
standalone API.
2021-08-10 09:27:59 -04:00
Raymond Hill
b54bf554a8
Fix bad test in WASM version of HNTrieContainer
The erroneous test does not seem to interfere
with the proper functioning of the trie, due
to the fact that nodes are never split without
a OR node or boundary node being present.

The issue was found when undertaking a rewrite
of the algorithm to avoid having to create
boundary nodes.
2021-08-09 07:02:00 -04:00
Raymond Hill
385acd7b0a
Fix eslint error 2021-08-08 11:49:31 -04:00
Raymond Hill
22768ddcd0
Remove undue dependencies on vAPI
Whether WebAssembly can be enabled or not should be
decided at a higher level.
2021-08-08 11:41:05 -04:00
Raymond Hill
7cd583a301
Revisit the nodejs API 2021-08-08 09:17:14 -04:00
Raymond Hill
4818405cf6
Remove need to pass parser at every compile() call
The compiler instance is already initialized with a
reference to the parser, no need to keep passing the
reference at each call to compile().
2021-08-05 13:30:20 -04:00
Raymond Hill
85c68116bd
Group all compiling-related code into FilterCompiler() class
In the static network filtering engine (snfe), the
compiling-related code was spread across two classes.
This commit makes it so that all the compiling-related
code is in FilterCompiler class, which clear purpose is
to compile raw filters into a form which can be persisted
and later fed to the snfe with no parsing overhead.

To compile raw static network filter, the new approach is:

    snfe.createCompiler(parser);

Then for each single raw filter to compile:

    compiler.compile(parser, writer);

The caller is responsible to keep a reference to the
compiler instance for as long as it is needed. This removes
the need for the clunky code used to keep an instance of
compiler alive in the snfe.

Additionally, snfe.tokenHistograms() has been moved to
benchmarks.js, as it has no dependency on the snfe, it's
just a utility function.
2021-08-04 15:14:48 -04:00
Raymond Hill
5e8f847aeb
Fix regression in cloud storage upload/download
Reported in team discussion

Regression from:
- 22022f636f
2021-08-03 14:03:00 -04:00
Raymond Hill
89c5653bc6
Export the rule-based filtering engines to the nodejs package
The code exported to nodejs package was revised to use modern
JavaScript syntax. A few issues were fixed at the same time.

The exported classes are:
- DynamicHostRuleFiltering
- DynamicURLRuleFiltering
- DynamicSwitchRuleFiltering

These related to the content the of "My rules" pane in the
uBlock Origin extension.
2021-08-03 12:19:25 -04:00
Manish Jethani
6ef74fc21b
Rewrite logical expressions for ESLint (#3801) 2021-08-03 10:59:01 -04:00
Manish Jethani
3ca5e6817d
Fix ESLint indentation warnings (#3800)
* Fix ESLint indentation warnings

* Undo code reformatting within parentheses

* Add exception for logical expressions

* Update array expression rule

* Disable rule for reProceduralOperator assignment

* Fix indentation in static-filtering-parser.js
2021-08-03 10:14:40 -04:00
Manish Jethani
ad69c760fb
Run ESLint during Node.js package generation (#3798) 2021-08-02 16:55:03 -04:00
Raymond Hill
f8daea085b
Remove assets dependency from redirect engine
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1664

This change allows to add the redirect engine into the
nodejs package. The purpose of the redirect engine is to
resolve a redirect token into a path to a local resource,
to be used by the caller as wished.
2021-08-02 09:23:48 -04:00
vt
2b9aba2748 Handle invalid meta refresh URLs in noscript scriptlet
Invalid URLs like "http://" and "http://foo@" trigger TypeErrors
when they are passed to the URL constructor. These TypeErrors
caused the scriptlet to stop processing subsequent noscript nodes
due to uncaught exceptions.

These exceptions are now caught to allow all noscript nodes to
be processed.
2021-07-31 13:16:33 -04:00
Raymond Hill
cb72211795
Move orphanizeString() into text-utils module
Another small step toward the goal of reducing dependency
on `µb`.

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1664

text-iterators module has been renamed text-utils to better
reflect its content.
2021-07-31 08:38:33 -04:00
Raymond Hill
dc08478130
Fix https://github.com/uBlockOrigin/uBlock-issues/issues/1675 2021-07-31 07:15:19 -04:00
Raymond Hill
076a088371
Remove stray async 2021-07-29 17:04:32 -04:00
Raymond Hill
98fc66bb1b
Add support for enabling WASM code paths in NodeJS package
See `test.js` for reference on how to enable WASM code
paths (which are disabled by default).
2021-07-29 16:54:51 -04:00
Raymond Hill
8ef8c5ab2e
Group all benchmarking functions in a separate file
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1664

The various filtering engine benchmarking functions are best
isolated in their own file since they have specific
dependencies that should not be suffered by the filtering
engines.

Additionally, moved decomposeHostname() into uri-utils.js
as it's a hostname-related function required by many
filtering engine cores -- this allows to further reduce
or outright remove dependency on `µb`.
2021-07-29 08:44:15 -04:00
Raymond Hill
62b6826dd5
Further modularize uBO's codebase
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1664

Modularization is a necessary step toward possibly publishing
a more complete nodejs package to allow using uBO's filtering
capabilities outside of the uBO extension.

Additionally, as per feedback, remove undue usage of console
output as per feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1664#issuecomment-888451032
2021-07-28 19:48:38 -04:00
Raymond Hill
22022f636f
Modularize codebase with export/import
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1664

The changes are enough to fulfill the related issue.

A new platform has been added in order to allow for building
a NodeJS package. From the root of the project:

    ./tools/make-nodejs

This will create new uBlock0.nodejs directory in the
./dist/build directory, which is a valid NodeJS package.

From the root of the package, you can try:

    node test

This will instantiate a static network filtering engine,
populated by easylist and easyprivacy, which can be used
to match network requests by filling the appropriate
filtering context object.

The test.js file contains code which is typical example
of usage of the package.

Limitations: the NodeJS package can't execute the WASM
versions of the code since the WASM module requires the
use of fetch(), which is not available in NodeJS.

This is a first pass at modularizing the codebase, and
while at it a number of opportunistic small rewrites
have also been made.

This commit requires the minimum supported version for
Chromium and Firefox be raised to 61 and 60 respectively.
2021-07-27 17:26:04 -04:00
Raymond Hill
89064478dd
Modernize code: URLSearchParams() API support is now widespread 2021-07-25 07:08:03 -04:00
Raymond Hill
c25938f5bc
Ensure compiled sections are ordered in ascending id
Related issue:
- https://www.reddit.com/r/uBlockOrigin/comments/oq6kt5/ubo_loads_generic_filter_instead_of_specific/h6a4nca/
2021-07-24 07:44:26 -04:00
Raymond Hill
51d14de44a
Fix handling of some procedural cosmetic filters with explicit :scope
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1011#issuecomment-884806241
2021-07-23 10:11:07 -04:00
Raymond Hill
cd237ed3e1
Fix rendering of punycoded hostname in popup panel
Regression from:
- 75deadd31e
2021-07-20 11:22:33 -04:00
Raymond Hill
75deadd31e
Provide visual cue in popup panel when base domain has subdomains
Related issue:
- https://github.com/gorhill/uBlock/issues/284
2021-07-20 08:37:05 -04:00
Raymond Hill
e85c6f2d3e
Merge background changes to user filters in "My filters" pane
Related issue:
- https://github.com/gorhill/uBlock/issues/3704
2021-07-17 12:03:56 -04:00
Raymond Hill
e3f8a612f4
Minor code review 2021-07-16 14:06:59 -04:00
Raymond Hill
ec7db30b2f
Simplify fetching title of tabs
The title of tabs in uBO is solely to have a better
presentation in the logger -- no other purpose.

This commit simplify keeping track of the titles, from
an active approach by directly querying it from tabs
whenever a change occurs, to a passive approach by
storing it when the title string become available in
some tab event handlers.
2021-07-16 08:59:30 -04:00
Raymond Hill
bbdb68a2b6
Synthesize missing expected onCreatedNavigationTarget events
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1659

This commit introduces a workaround for missing
onCreatedNavigationTarget() in Chromium.
2021-07-15 11:34:37 -04:00
Raymond Hill
e03bb99f57
Add neutered replacement script for mixpanel
Related discussion:
- https://www.reddit.com/r/uBlockOrigin/comments/oicch9/

The new replacement script contains the smallest API
possible to resolve the reported case.

Please report instances where it's not sufficient to
unbreak a site, in which case I will extend the neutered
API to address these cases on an on-demand basis.
2021-07-13 07:58:31 -04:00
Raymond Hill
9a60573abe
Fix broken "Block element..." case when cosmetic filtering is off
Related feedback:
- e983f9a76e (commitcomment-53382148)
2021-07-12 18:32:32 -04:00
Raymond Hill
e983f9a76e
Disable creation of cosmetic filters in picker when unenforceable
Related issue:
- https://github.com/gorhill/uBlock/issues/3212

The element picker will now properly work on sites where
cosmetic filtering is disabled, but will not allow the
creation of cosmetic filters when specific cosmetic filters
are not meant to be enforced in the current page.

When specific cosmetic filters are not meant to be enforced,
the element picker will still allow the creation of network
filters, that is unless the current page is trusted, in which
case using the element picker is pointless.
2021-07-12 11:55:58 -04:00
Raymond Hill
f1a453d349
Avoid pointless check of doc id, presence of doc origin is what matter
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1657
2021-07-12 11:26:25 -04:00
Raymond Hill
717d8593c5
Improve the logger accuracy regarding matched part of the URL
Related issue:
- https://github.com/gorhill/uBlock/issues/3037

This takes care of the specific case reported. There are
other edge cases which are likely not addressed though, i.e.
those involving wildcards -- those should be rather rare and
at this point I rather leave them unaddressed to not
risk regressions (as they are less trivial to address).
2021-07-11 10:11:26 -04:00
Raymond Hill
27c633e054
Better handle negated behhvior types
Related issue:
- https://github.com/gorhill/uBlock/issues/2385
2021-07-10 16:35:52 -04:00
Raymond Hill
ed5dd0a791
Use location.replace() to modify URL of embedded frame
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1648
2021-07-10 09:56:36 -04:00
Raymond Hill
b75921c2fd
Limit recursion when parsing URL in document-blocked page
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1649
2021-07-06 10:13:50 -04:00
Raymond Hill
4422c42788
Discard network filters containing invalid pattern characters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1146
2021-06-26 12:12:25 -04:00
Raymond Hill
b41463d437
Skip handling non-media elements 2021-06-25 07:24:00 -04:00
Raymond Hill
163035dc92
Drop the v from build version 2021-06-25 07:18:11 -04:00
Raymond Hill
14076fe8c0
Take care of misreporting spurious filter syntax error
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1596
2021-06-24 11:48:27 -04:00
Raymond Hill
81521256e7
Exclude trusted sites from no-popups-switch
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1616
2021-06-24 11:02:06 -04:00
Raymond Hill
ad15a5dd51
Map csp_report to other
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1622
2021-06-24 08:09:18 -04:00
Raymond Hill
090614dd18
Use firstElementChild instead of childElementCount
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1620

Related bugzilla issue:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1715841
2021-06-17 09:58:18 -04:00
Raymond Hill
8877ea290e
Do not redirect when no query parameters are removed
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1626
2021-06-12 13:26:21 -04:00
Raymond Hill
32bd47f053
Force restart at first install for Chromium-based browsers
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1547

The approach used to fix the issue was confirmed working
in the following related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1608#issuecomment-856282345
2021-06-12 09:18:56 -04:00
Raymond Hill
eb519b2ec1
Ensure version changes are persisted at launch 2021-06-02 07:07:10 -04:00
Raymond Hill
37ad821018
Fix loss of newlines when processing pre-parsing directives
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1603
2021-05-26 07:51:10 -04:00
Raymond Hill
7508700892
Prevent unchecked default lists from being visually collapsed
Related issue:
- https://github.com/gorhill/uBlock/issues/2303
2021-05-19 09:34:46 -04:00
Raymond Hill
8cd2a1d263
Make googletagmanager_gtm.js an alias of google-analytics_analytics.js
Related feedback:
- https://ilakovac.com/teespring-ublock-issue/

The surrogate script googletagmanager_gtm.js was essentially a
subset of surrogate script google-analytics_analytics.js. This
commit makes it a plain alias so that the whole GA API -- often
expected by clients of GTM -- is properly stubbed.
2021-05-18 11:08:20 -04:00
Raymond Hill
3fa7316062
Minor code review
Related commit:
- a24e2a5d6c
2021-05-16 08:16:13 -04:00
Raymond Hill
a24e2a5d6c
Fix management of reload button in popup panel
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1461
2021-05-15 10:45:31 -04:00
Raymond Hill
001094580c
Allow filter list subscription through context menu
Related issue/feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/763#issuecomment-841582704
2021-05-15 08:15:57 -04:00
Raymond Hill
d0e4c60f59
Keep reporting last time "out of date" lists were updated 2021-05-09 11:53:26 -04:00
Raymond Hill
1f8a67f40e
Fix improper hashing of rules in classic popup panel
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/n5vaih/
2021-05-09 11:41:23 -04:00
Raymond Hill
fca4db8021
Better handle network error when fetching sublist
Reported internally:

> STR --
>
> Import https://cdn.statically.io/gh/uBlockOrigin/uAssets/master/filters/filters.txt
> as a Custom filter list.
>
> Observe the filter count at 24K instead of true count
> being 29K.
>
> Force updating is sometimes compiling 24K filters and
> on subsequent updates 29K, so I narrowed it down to
> this host.

Findings:

One of the sublists was erroring when being fetched on
this particular CDN server (reason unknown).

uBO was not properly handling network errors when
fetching a sublist. This commit make it so that if
a sublist can't be fetched, then the error is propagated
as if it affected the whole list, in which case uBO will
use an alternative URL if any.
2021-04-29 08:32:32 -04:00
Raymond Hill
81fadf836f
Stop autoplay for unset media source with no-large-media-elements
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/mxgpmc/
2021-04-27 08:59:59 -04:00
Raymond Hill
2a5e67e3f5
Use CDN URLs as fall back URLs
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1566#issuecomment-826473517

Additionally, add more CDN URLs to default filter lists.
2021-04-27 08:56:07 -04:00
Raymond Hill
912bdce9cd
Normalize removeparam to removeparam, not queryprune 2021-04-16 08:59:57 -04:00
Raymond Hill
bc8c1d00ad
Remove advanced setting ignoreScriptInjectFilters
This advanced setting is not really needed, as the
same can be accomplished with a broad exception
filter such as `#@#+js()`.

Related feedback:
- f5b453fae3 (commitcomment-49499082)
2021-04-14 10:56:04 -04:00
Raymond Hill
58505cfddc
Finalize 3rd-party scripts/frames mini-filtering widget
For now the mini-filtering widget on 3rd-party scripts/frames
cells will allow to emphasize rows which have 3rd-party
scripts and/or frames.

Somewhat related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/210
2021-04-13 09:08:53 -04:00
Raymond Hill
f5b453fae3
Remove advanced setting ignoreScriptInjectFilters
Ever since the `redirect` code was refactored:

157cef6034

This advanced setting is no longer needed, as the same
can be accomplished with a plain network filter:

    @@*$redirect-rule
2021-04-13 08:49:10 -04:00
Raymond Hill
bfdc81e9e4
Ensure FLoC is opt-in by default
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1553

This commit ensures FLoC is opt-in. The generic filter
`*##+js(no-floc)` in "uBlock filters -- Privacy" ensures
the feature is disabled when using default settings/lists.

Users can opt-in to FLoC by adding a generic exception
filter to their custom filters, `#@#+js(no-floc)`; or they
can opt-in only for a specific set of websites through a
more specific exception filter:

    example.com,shopping.example#@#+js(no-floc)
2021-04-11 09:36:56 -04:00
Raymond Hill
9a94ba0a22
Fix regex used to extract attribute name in element picker
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/mh2ctv/
2021-03-31 12:21:29 -04:00
Raymond Hill
b1228f9d51
Add missing new JS file
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1527#issuecomment-798449462

Related commit:
- f876b68171
2021-03-13 09:38:29 -05:00
Raymond Hill
5e5bc24f63
Alphabetical order 2021-03-13 09:05:54 -05:00
Raymond Hill
f876b68171
Add support for removal of response headers
The syntax to remove response header is a special case
of HTML filtering, whereas the response headers are
targeted, rather than the response body:

  example.com##^responseheader(header-name)

Where `header-name` is the name of the header to
remove, and must always be lowercase.

The removal of response headers can only be applied to
document resources, i.e. main- or sub-frames.

Only a limited set of headers can be targeted for
removal:

  location
  refresh
  report-to
  set-cookie

This limitation is to ensure that uBO never lowers the
security profile of web pages, i.e. we wouldn't want to
remove `content-security-policy`.

Given that the header removal occurs at onHeaderReceived
time, this new ability works for all browsers.

The motivation for this new filtering ability is instance
of website using a `refresh` header to redirect a visitor
to an undesirable destination after a few seconds.
2021-03-13 08:53:34 -05:00
Raymond Hill
a01c03e11a
Fix no-scripting switch not working for SVG-based documents
Issue spotted while trying the following page:
- https://www.xul.fr/svgtetris.svg
2021-03-06 08:18:46 -05:00
Raymond Hill
9f063c717b
Also CSS-escape tag name in element picker
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1519
2021-03-04 06:19:44 -05:00
Raymond Hill
404e6252d6
Fix regression causing exceptions to be thrown
Related commit:
- 1c3b45f75d

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1513
2021-03-03 10:51:56 -05:00
Raymond Hill
1c3b45f75d
Expose ability to toggle on/off cname-uncloaking to all users
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1513

Prior to this commit, the ability to enable/disable the
uncloaking of canonical names was only available to advanced
users. This commit make it so that the setting can be
toggled from the _Settings_ pane.

The setting is enabled by default. The documentation should
be clear that the setting should not be disabled unless it
actually solves serious network issues, for example:

https://bugzilla.mozilla.org/show_bug.cgi?id=1694404

Also, as a result, the advanced setting `cnameUncloak` is no
longer available from within the advanced settings editor.
2021-03-02 13:00:56 -05:00
Raymond Hill
972feae05d
Drop ctrl-key requirement in "Purge all caches" operation
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/lrcwii/memory_use_in_roaming_profile_in_windows/goq6h4n/
2021-02-26 06:48:26 -05:00
Raymond Hill
b7a2352c6f
Do not suggest network filters with wildcarded hostname in picker
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1494
2021-02-22 07:57:23 -05:00
Raymond Hill
918a073c81
Fix regression in strict blocking
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/lp6dwp/

Regression from:
- 3af1120082
2021-02-22 06:32:43 -05:00
Raymond Hill
266a7507b8
Fix regression when initializing popup panel
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1505

Regression from:
- 435c91636f
2021-02-21 07:41:09 -05:00
Raymond Hill
3565a0511e
Update comment
DOM logger and inspector are loaded on demand.
2021-02-20 07:05:19 -05:00
Raymond Hill
dfa1b64cae
Fix regression when reverting temporary rules in popup panel
Refression from:
- 435c91636f
2021-02-19 12:32:07 -05:00
Raymond Hill
3af1120082
Add support for exception of document to bypass strict-blocking
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1501

Exception filters for `document` option are complying with
uBO's own semantic for `document` option, i.e. an exception
filter for `document` option will only allow to bypass a
block filter for `document` (either explicit or implicit)
and nothing else.

Exception filters using `document` option are *not*
compatible with ABP's interpretation of these filters.
Whereas in ABP the purpose of a `document` exception filter
is to wholly disable content blocking, in uBO the same
filter will just cause strict-blocking to be disabled while
leaving content blocking intact.

Additionally, the logger was fixed to properly report pages
which are being strict-blocked.
2021-02-19 08:38:50 -05:00
Raymond Hill
96049f147e
Reflect latest changes in comment 2021-02-19 08:38:07 -05:00
Raymond Hill
9c3205b37c
Inject procedural cosmetic filterer's code only when needed
The procedural cosmetic filtering code has been split from
the content script code injected unconditionally and will
from now on be injected only when it is needed, i.e. when
there are procedural cosmetic filters to enforce.

The motivation for this is:
https://www.debugbear.com/blog/2020-chrome-extension-performance-report#what-can-extension-developers-do-to-keep-their-extensions-fast

Though uBO's content script injected unconditionally in all
pages/frames is relatively small, I still wanted to further
reduce the amount of content script code injected
unconditionally: The procedural cosmetic filtering code
represents roughly 14KB of code the browser won't have to
parse/execute unconditionally unless there exists procedural
cosmetic filters to enforce for a page or frame.

At the time the above article was published, the total
size of unconditional content scripts injected by uBO was
~101 KB, while after this commit, the total size will be
~57 KB (keeping in mind uBO does not minify and does not
remove comments from its JavaScript code).

Additionally, some refactoring on how user stylesheets are
injected so as to ensure that `:style`-based procedural
filters which are essentially declarative are injected
earlier along with plain, non-procedural cosmetic filters.
2021-02-17 09:12:00 -05:00
Raymond Hill
435c91636f
Count allowed/blocked requests for 3rd-party scripts/frames
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/210

Additionally, a small (experimental) widget has been added
to emphasize/de-emphasize rows which have 3rd-party
scripts/frames, so as to more easily identify which rows
are "affected" by 3rd-party scripts and/or frames.

Tooltip localization for the new widget is not available
yet as I want wait for the feature to be fully settled.
2021-02-15 06:52:31 -05:00
Raymond Hill
3bb73065e3
Fix broken forward compatibility re. imported lists
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1480

Forward compatiblity was broken due to `externalLists`
being converted into an Array from a string, i.e.
downgrading to uBO 1.32.4 was completely breaking uBO.

This commit restores `externalLists` as a string which
is what older versions of uBO expect.

A new property `importedLists` has been created to
hold the imported lists as an array, while
`externalLists` will be kept around for a while until
it is completely removed in some future.
2021-01-31 10:30:12 -05:00
Raymond Hill
0390bb8b8a
Fix potential spurious redirection in whitelisted tabless contexts
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1478
2021-01-30 15:08:21 -05:00
Raymond Hill
3101c5fa22
Upload non-filtered rules to cloud storage
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1472
2021-01-28 09:43:14 -05:00
Raymond Hill
40c145d76a
Fix handling of cname-aliased URLs in click-to-load widget
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1455
2021-01-22 09:37:12 -05:00
Raymond Hill
174731851e
Minor fine tuning of some default parameters 2021-01-21 08:40:10 -05:00
Raymond Hill
6eb1246508
Add userSettings entry to managed storage
The managed `userSettings` entry is an array of entries,
where each entry is a name/value pair encoded into an array
of strings.

The first item in the entry array is the name of a setting,
and the second item is the stringified value for the
setting.

This is a more convenient way for administrators to set
specific user settings. The settings set through
`userSettings` policy will always be set at uBO launch
time.
2021-01-16 10:35:56 -05:00
Raymond Hill
649b3480e0
Add "toOverwrite.filters" entry as managed storage property
The new entry is an array of strings, each representing a
distinct line, and all entries are used to populate the
"My filters" pane.

This offers an more straightforward way for administrators
to specify a list of custom filters to use for all
installations.
2021-01-10 12:31:31 -05:00
Raymond Hill
114012ae11
Add ability to lookup effective context from store of frames
Content scripts can't properly look up effective context
for sandboxed frames. This commit add ability to extract
effective context from already existing store of frames
used for each tab.
2021-01-10 11:56:27 -05:00
Raymond Hill
03e1b16961
Fix content script's broken context lookup from sandboxed anonymous frames 2021-01-08 13:12:48 -05:00
Raymond Hill
0e3071dd50
Add filterLists property to managed storage
The entry `toOverwrite.filterLists` is an array of
string, where each string is a token identifying a
stock filter list, or a URL for an external filter
list.

This new entry is to make it easier for an
administrator to centrally configure uBO with a
custom set of filter lists.
2021-01-08 09:18:26 -05:00
Raymond Hill
e4e7cbc78f
Use better identifying name for overview panel 2021-01-07 08:19:47 -05:00
Raymond Hill
1fcc3c6ddc
Add URL as tooltip 2021-01-07 08:19:02 -05:00
Raymond Hill
cc9c45f1e4
Adding to and further reviewing admin-managed settings 2021-01-06 11:39:24 -05:00
Raymond Hill
2ab11603f0
Allow everybody to use now-stable queryprune=
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/760
2021-01-06 11:17:07 -05:00
Raymond Hill
c1130ec843
Add support for admin-managed hidden settings
Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1437#issuecomment-754127066
2021-01-05 12:16:50 -05:00
Raymond Hill
b28acfccbc
Add "extraTrustedSiteDirectives" as new admin policy
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1433

The new "extraTrustedSiteDirectives" policy is an array
of strings, each of which is parsed as a trusted-site
directive to append to a user's own set of trusted-site
directives at launch time.

The added trusted-site directives will be considered as
part of the default set of directives by uBO.
2021-01-04 07:54:24 -05:00
Raymond Hill
2bb33aac20
Be sure to use only a valid journal slot pointer
Related commit:
- 70cabc1cc6
2021-01-02 12:41:13 -05:00
Raymond Hill
752191a04f
Make sure journal slot pointers are properly reset
For when the same page store is recycled later.
2021-01-02 12:07:31 -05:00
Raymond Hill
70cabc1cc6
Better report secondary requests with quick redirections
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1241

uBO will not discard secondary requests fired before a root
frame is committed, by ensuring that if newly uncommitted
root frames are of the same origin as previous one(s), the
uncommited journal slot pointer is not updated.
2021-01-02 11:52:16 -05:00
Raymond Hill
c2357c5cd6
Just extract token from queryprune -- don't create pattern
Related commit:
- 6ac09a2856

Patternless `queryprune` ar enow preserved as being
pattern-less while still attempting to extract a token
from the `queryprune` value. This allows to report the
filter in the logger same as its original form.
2021-01-01 10:23:40 -05:00
Raymond Hill
1669d122df
Add resource for noop VMAP
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1425

The resource content is a copy/paste of AdGuard's code:
- bc5eec1989/src/redirects/static-redirects.yml (L134)
2020-12-29 09:05:28 -05:00
Raymond Hill
2e7f1b8d08
Improve validation of synctactically bad regexes
The following regex are not rejected as invalid when
using built-in regex objects:

    /abc]/
    /a7,18}/
    /a{7,18/

However, as per documentation, they are not supposed to
be valid, as `{` and `}` are special characters and as
such should be escaped:

    /abc\]/
    /a7,18\}/
    /a\{7,18/

With this commit, the regexes will additionally be
validated using the regex analyzer library in the editor
to ensure strict regex syntax compliance so as to avoid
what are likely mistakes in regex crafting by authors.
2020-12-28 07:13:57 -05:00
Raymond Hill
4ba3adc28c
Fix comment 2020-12-28 07:07:04 -05:00
Raymond Hill
d910111d4a
Fix parsing of trailing resource
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1419
2020-12-28 07:03:52 -05:00
Raymond Hill
6d3ad553b4
Fix word-based selection in filter list editor/viewer
This commit fixes mouse double-click-and-drag operations,
which was broken due to the implementation of a custom
word selection in the filter list editor/viewer.
2020-12-27 09:32:50 -05:00
Raymond Hill
b053477087
Fix potentially missing context in logger for popup entries
Reported internally.
2020-12-26 10:15:07 -05:00
Raymond Hill
426395aa03
Improve extraction of tokens from regex-based filters
Regex-based static network filters are those most likely to
cause performance degradation, and as such the best guard
against undue performance degradation caused by regex-based
filters is the ability to extract valid and good tokens
from regex patterns.

This commit introduces a complete regex parser so that the
static network filtering engine can now safely extract
tokens regardless of the complexity of the regex pattern.

The regex parser is a library imported from:
https://github.com/foo123/RegexAnalyzer

The syntax highlighter adds an underline to regex-based
filters as a visual aid to filter authors so as to avoid
mistakenly creating regex-based filters. This commit
further colors the underline as a warning when a regex-based
filter is found to be untokenizable.

Filter list authors are invited to spot these untokenizable
regex-based filters in their lists to verify that no
mistake were made for those filters, causing them to be
untokenizabke. For example, what appears to be a mistake:

    /^https?:\/\/.*\/sw.js?.[a-zA-Z0-9%]{50,}/

Though the mistake is minor, the regex-based filter above
is untokenizable as a result, and become tokenizable when
the `.` is properly escaped:

    /^https?:\/\/.*\/sw\.js?.[a-zA-Z0-9%]{50,}/

Filter list authors can use this search expression in the
asset viewer to find instances of regex-based filters:

    /^(@@)?\/[^\n]+\/(\$|$)/
2020-12-26 08:52:42 -05:00
Raymond Hill
596f085fa5
Allow default word selection when not using better selection
Double-click in editor will just fall back to default word
selection when NOT using enhanced word selection.
2020-12-24 08:34:45 -05:00
Raymond Hill
1c37e29e0a
Fix handling of fragment when applying queryprune
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1415
2020-12-24 07:35:26 -05:00
Raymond Hill
ea71e93c81
Reset Chromium-specific color-scheme CSS property
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1408
2020-12-21 09:20:56 -05:00
Raymond Hill
187f1831f0
Allow more local resources to be redirected as data: URIs
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1388#issuecomment-748625280
2020-12-20 11:54:24 -05:00
Raymond Hill
990cff576d
Fix case of scriptlet injection not working about: frames
This is an issue in uBO affecting only Chromium-based browsers.

Related feedback:
https://github.com/uBlockOrigin/uBlock-issues/issues/688#issuecomment-748179731
2020-12-18 12:07:08 -05:00
Raymond Hill
a307cf5e6a
Mind restore-from-backup for no-csp-reports rule
Related commit:
- 7d90f97aa1
2020-12-17 08:12:06 -05:00
Raymond Hill
bc9b8a1330
Enable broad no-csp-reports rule only in Firefox
Related commit:
- 7d90f97aa1
2020-12-16 07:02:55 -05:00
Raymond Hill
89cac090a4
Mind important only for valid redirect tokens
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1366#issuecomment-745744824
2020-12-16 06:55:46 -05:00
Raymond Hill
a090b2b564
Fix auto-completion for epicker in Firefox 2020-12-15 09:38:20 -05:00
Raymond Hill
0052dc123b
Fix no-csp-reports default enabled switch state
Related feedback:
- 7d90f97aa1 (commitcomment-45138096)
2020-12-15 09:36:04 -05:00
Raymond Hill
e28c2cc3c6
Auto-complete of origin pattern for ||-based patterns
Related commit:
- daf464b3c3
2020-12-15 08:27:59 -05:00
Raymond Hill
8060ddb283
Avoid duplicates in editor's auto-completion of origins
Related commit:
- daf464b3c3
2020-12-14 11:26:04 -05:00
Raymond Hill
b22cf24bd5
Fix look-up of specific-generic filters entity-less hostnames
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/688#issuecomment-743755956
2020-12-14 11:22:08 -05:00
Raymond Hill
d4425ad753
Fix bad access to hostname info from filtering context
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1398

Regression from:
- 6df32675b1
2020-12-14 08:38:30 -05:00
Raymond Hill
1ff8132216
Simplify code
Related commit:
- b779f1f7c9
2020-12-13 12:14:37 -05:00
Raymond Hill
18e6f30c1c
Minor code review
Related commit:
- 6df32675b1
2020-12-12 14:38:44 -05:00
Raymond Hill
b779f1f7c9
Dynamically reload 3p css when noop-ing "3rd-party" cell
This should improve usability of uBO's hard-mode
and "relax blocking mode" operations. This is the
new default behavior.

The previous behavior of forcing a reload of the
page can be re-enabled by simply setting the `3p`
bit of the advanced setting `blockingProfiles`
to 1.
2020-12-12 14:33:49 -05:00
Raymond Hill
6df32675b1
Add approximate reporting of tabless network requests
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1204

Not much can be done beside reporting to tabless network
requests to all tabs for which the context is a match.

A short term local cache is used to avoid having to iterate
through all existing tabs for each tabless network request
just to find and report to the matching ones -- users
reporting having a lot of opened tabs at once is not so
uncommon.
2020-12-12 08:19:40 -05:00
Raymond Hill
7d90f97aa1
Enable the blocking of CSP reports by default
Related issue:
- https://github.com/LiCybora/NanoDefenderFirefox/issues/196
2020-12-11 12:34:09 -05:00
Raymond Hill
24755d4300
Fix broken alias nostif
Related feedback:
- ba11a70013 (r45030152)

Regression from:
- ba11a70013
2020-12-11 10:34:33 -05:00
Raymond Hill
cb71fb494c
Fix DOM watcher not reporting removal of elements
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1392

Regression from:
- 6112a68faf
2020-12-10 12:51:26 -05:00
Raymond Hill
15afd59e1e
Fix unstyling of nodes no longer matching procedural filters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1392

Regression from:
- 35aefed926
2020-12-10 10:03:15 -05:00
Raymond Hill
0b5f53923f
Add basic compatibility with ABP's rewrite option
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/857

The recognized resources are:
- abp-resource:blank-mp3
- abp-resource:blank-js

ABP's tokens are excluded from auto-complete so as to not
get in the way of uBO's filter list maintainers.
2020-12-09 08:16:28 -05:00
Raymond Hill
3ff6617ea3
Fix block filter reported in the logger despite being excepted
Reported internally by @uBlock-user.

Also, fixed broken caching of `cname` exception, which forced
uBO to repeatedly evaluate whether a `cname` exception exists
when a block `cname`-cloaked request is encountered.
2020-12-08 11:16:17 -05:00
Raymond Hill
9aef41738b
Prevent non-stable uiTheme from being used in stable build
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1389

Asking people to respect the warning in the documentation
does not work, consequently the setting will be now disabled
for stable releases.
2020-12-08 10:11:34 -05:00
Raymond Hill
5d7b2918ef
Harden processing of changes in compiled list format
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1365

This commit adds the compiled magic version number to the
compiled data itself, and consequently this allows uBO
to no longer require that any given compiled list with a
mismatched format to be detected and discarded at launch
time.

Given this change, uBO no longer needs to rely on the
deletion of cached data at launch time to ensure it
won't use no longer valid compiled lists.
2020-12-08 10:00:47 -05:00
Raymond Hill
780b605bad
Fix missing magnifier in document-blocked page
Related feedback:
- e559cb73b9 (commitcomment-44887972)

Regression from:
- e559cb73b9
2020-12-07 14:32:59 -05:00
Raymond Hill
904aa87e2a
Fix various regression in behavior of redirect-rule=
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1388

Fixed the special `none` redirect resource no longer being
enforced.

Fixed the enforcement of `important` redirect rules over
exceptions and non-important ones.
2020-12-07 11:12:41 -05:00
Raymond Hill
5d7a5a559d
Fix broken redirect-rule= priority parser
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1388

Regression from:
- cf2c638d8e
2020-12-07 10:49:05 -05:00
Raymond Hill
e559cb73b9
Complete removal of font-based Fontawesome icons
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/249
2020-12-06 11:24:04 -05:00
Raymond Hill
db7f54dbf6
Add support to launch element picker in embedded frames
Related issue:
- https://github.com/gorhill/uBlock/issues/1744

A new context menu entry, "Block element in frame...", will
be present when right-clicking on a frame element. When
this entry is clicked, uBO's element picker will be
launched from within the embedded frame and function the
same way as when launched from within the page.
2020-12-05 15:26:29 -05:00
Raymond Hill
c77f697b4b
Reuse duplicate strings stored in tries
This is particularly helpful for static network filters
used with filter options causing the same pattern to be
reused across multiple filter instances, i.e. `all` or
`~css`, etc.
2020-12-04 07:53:01 -05:00
Raymond Hill
e8e4a1ac74
Wait for removal of storage entries to be completed
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1365

When compiled data format changes, do not rely on order
of operations at launch to assume deletion of storage
occurs before attempts to access it. It's unclear this
commit will fix the reported issue, as I could not
reproduce it except when outright commenting out the code
to prevent the storage deletion from occurring.
2020-12-04 06:17:18 -05:00
Raymond Hill
da9d068243
Fix improper typeof test for string type
Regression from:
- b12e0e05ea

This broke the ability to provide a link to the actual
asset on the remote server in the asset viewer.
2020-12-03 11:52:49 -05:00
Raymond Hill
1de8349045
Fix hint helper in element picker's text editor
Regression from:
- 262a1a044f
2020-12-03 07:34:50 -05:00
Raymond Hill
ee87bda326
Fix regression in syntax rendering of redirect values in asset viewer
Related commit:
- 262a1a044f
2020-12-02 13:07:29 -05:00
Raymond Hill
262a1a044f
Improve auto-complete of hostname values in "My filters"
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1134

Related commit:
- daf464b3c3
2020-12-02 09:09:28 -05:00
Raymond Hill
26dc7a1490
Minor review of redirect-related code
Notably, I finally settled for implicit priority of
0, but now negative priority values are allowed.
2020-12-02 08:18:55 -05:00
Raymond Hill
cf2c638d8e
Improve reporting of matching redirect= rules in logger
All matching `redirect-rule` directives will now be reported
in the logger, instead of just the effective one.

The highest-ranked redirect directive will be the one
effectively used for redirection. This way filter list
authors can see whether a lower priority redirect is
being overriden by a higher priority one.

The default priority has been changed to 10, so as to allow
more leeway to create lower ranked redirect directives.

Additonally, rendering of redirect directives with explicit
priority has been fixed in the logger, they will no longer
be rendered as unknown redirect tokens.
2020-12-01 09:29:40 -05:00
Raymond Hill
e08f8cb001
Make queryprune an exact alias of removeparam
As per agreed upon discussion, `queryprune` now follows
exactly the syntax of AdGuard's `removeparam`.

Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1356

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/760

For the short term, `queryprune` will still interpret a
leading `|` to mean "anchor to start of name", until no
such filters are present in uBO's own filter lists.
2020-11-30 12:52:37 -05:00
Raymond Hill
391a5c99c7
Fix the parsing of unsupported static network filter types
Related issue:
- https://github.com/gorhill/uBlock/issues/2283

This is a regression causing the referenced issue to no
longer be fixed. The regression was introduced when the
new static filtering parser code was introduced in version
1.28.0:

https://github.com/gorhill/uBlock/releases/tag/1.28.0
2020-11-30 12:02:36 -05:00
Raymond Hill
5db8d05975
Better align syntax of header= option to that of queryprune=
The header value is no longer implicitly a regex-based literal, but
a plain string against which the header name is compared. The value can
be set to a regex literal by bracing the header value with the usual
forward slashes, `/.../`.

Examples:

    *$1p,strict3p,script,header=via:1.1 google
    *$1p,strict3p,script,header=via:/1\.1\s+google/

The first form will cause a strict comparison with the value of the header
named `via` against the string `1.1 google`.

The second form will cause a regex-based test with the value of the header
named `via` against the regex `/1\.1\s+google/`.

The header value can be prepended with `~` to reverse the comparison:

    *$1p,strict3p,script,header=via:~1.1 google

The header value is optional and may be ommitted to test only for the
presence of a specific header:

    *$1p,strict3p,script,header=via
2020-11-30 09:09:37 -05:00
Raymond Hill
ed64039912
Rename method 2020-11-29 14:03:33 -05:00
Raymond Hill
40a7c47bfc
Properly handle instances of #?# or #$# in picker
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1363#issuecomment-734957406
2020-11-29 11:31:20 -05:00
Raymond Hill
d1895d4749
Another round of fine-tuning queryprune= syntax
Related discussions:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1356#issuecomment-732411286
- https://github.com/AdguardTeam/CoreLibs/issues/1384

Changes:

Negation character is `~` (instead of `!`).

Drop special anchor character `|` -- leading `|`
will be supported until no such filter is present
in uBO's own filter lists. For example, instance
of `queryprune=|ad` will have to be replaced with
`queryprune=/^ad/` (or `queryprune=ad` if the name
of the parameter to remove is exactly `ad`).

Align semantic with that of AdGuard's `removeparam=`,
except that specifying multiple `|`-separated names
is not supported.
2020-11-29 11:02:40 -05:00
Raymond Hill
dac8d6becb
Fix broken token extraction
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1367

Regression from:
- 6ac09a2856

Need to mind wildcards adjacent to extracted token.
2020-11-29 07:38:15 -05:00
Raymond Hill
eae7cd58fe
Add support for match-case option; fine-tune behavior of redirect=
`match-case`
------------

Related issue:
- https://github.com/uBlockOrigin/uAssets/issues/8280#issuecomment-735245452

The new filter option `match-case` can be used only for
regex-based filters. Using `match-case` with any other
sort of filters will cause uBO to discard the filter.

`redirect=`
-----------

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1366

`redirect=` filters with unresolvable resource token at
runtime will be discarded.

Additionally, the implicit priority is now set to 1
(was 0). The idea is to allow custom `redirect=` filters
to be used strictly as fallback `redirect=` filters in case
another `redirect=` filter is not picked up.

For example, one might create a `redirect=click2load.html:0`
filter, to be taken if and only if the blocked resource is
not already being redirected by another "official" filter
in one of the enabled filter lists.
2020-11-28 11:26:28 -05:00
Raymond Hill
c6d0204b23
Remove requirement for presence of type with redirect= option
Related issue:
- https://github.com/gorhill/uBlock/issues/3590

Since the `redirect=` option was refactored into a modifier
filter, presence of a type (`script`, `xhr`, etc.) is no
longer a requirement.
2020-11-28 08:52:18 -05:00
Raymond Hill
ab5ab8575c
Avoid re-assigning asset cache registry at launch
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1365
2020-11-28 08:28:20 -05:00
Raymond Hill
c959fd6cd9
Fix comment 2020-11-27 16:01:34 -05:00
Raymond Hill
6ac09a2856
Add ability to parse removeparam= as queryprune=
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1356

Related commit:
- bde3164eb4

It is not possible to achieve perfect compatiblity at this
point, but reasonable compatibility should be achieved for
a majority of instances of `removeparam=`.

Notable differences:
--------------------

uBO always matches in a case insensitive manner, there is
no need to ask for case-insensitivity, and no need to use
uppercase characters in `queryprune=` values.

uBO does not escape special regex characters since the
`queryprune=` values are always assumed to be literal
regex expression (leaving out the documented special
characters). This means `removeparam=` with characters
which are special regex characters won't be properly
translated and are unlikely to work properly in uBO.

For example, the `queryprune` value of a filter such as
`$removeparam=__xts__[0]` internally become the literal
regex `/__xts__[0]/`, and consequently would not match
a query parameter such as `...?__xts__[0]=...`.

Notes:
------

Additionally, for performance reason, when uBO encounter
a pattern-less `queryprune=` (or `removeparam=`) filter,
it will try to extract a valid pattern from the
`queryprune=` value. For instance, the following filter:

    $queryprune=utm_campaign

Will be translated internally into:

    utm_campaign$queryprune=utm_campaign

The logger will reflect this internal translation.
2020-11-26 09:34:12 -05:00
Raymond Hill
80413dff83
Fix forgotton instances of 1P/3P
Related commit:
- 60d5b85e41

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1362
2020-11-26 05:43:14 -05:00
Raymond Hill
60d5b85e41
Rename 1P/3P tp strict1p/strict3p as suggested
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1362
2020-11-26 05:09:46 -05:00
Raymond Hill
57013c16e6
Fix compilation of blocking counterpart of redirect= filters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1358
2020-11-25 09:36:12 -05:00
Raymond Hill
e45949417b
Magic compile/selfie numbers need to increased
Related commit:
- bde3164eb4
2020-11-23 10:26:15 -05:00
Raymond Hill
43cb63f80a
Fix parsing of queryprune=* in static filtering parser 2020-11-23 08:47:29 -05:00