1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-29 22:27:12 +02:00
Commit Graph

2549 Commits

Author SHA1 Message Date
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
Raymond Hill
bde3164eb4
Add support for 1P, 3P, header= filter options and other changes
New filter options
==================

Strict partyness: `1P`, `3P`
----------------------------

The current options 1p/3p are meant to "weakly" match partyness, i.e. a
network request is considered 1st-party to its context as long as both the
context and the request share the same base domain.

The new partyness options are meant to check for strict partyness, i.e. a
network request will be considered 1st-party if and only if both the context
and the request share the same hostname.

For examples:

- context: `www.example.org`
- request: `www.example.org`
- `1p`: yes, `1P`: yes
- `3p`: no,  `3P`: no

- context: `www.example.org`
- request: `subdomain.example.org`
- `1p`: yes, `1P`: no
- `3p`: no,  `3P`: yes

- context: `www.example.org`
- request: `www.example.com`
- `1p`: no, `1P`: no
- `3p`: yes,  `3P`: yes

The strict partyness options will be visually emphasized in the editor so as
to prevent mistakenly using `1P` or `3P` where weak partyness is meant to be
used.

Filter on response headers: `header=`
-------------------------------------

Currently experimental and under evaluation. Disabled by default, enable by
toggling `filterOnHeaders` to `true` in advanced settings.

Ability to filter network requests according to whether a specific response
header is present and whether it matches or does not match a specific value.

For example:

    *$1p,3P,script,header=via:1\.1\s+google

The above filter is meant to block network requests which fullfill all the
following conditions:

- is weakly 1st-party to the context
- is not strictly 1st-party to the context
- is of type `script`
- has a response HTTP header named `via`, which value matches the regular
  expression `1\.1\s+google`.

The matches are always performed in a case-insensitive manner.

The header value is assumed to be a literal regular expression, except for
the following special characters:

- to anchor to start of string, use leading `|`, not `^`
- to anchor to end of string, use trailing `|`, not `$`
- to invert the test, use a leading `!`

To block a network request if it merely contains a specific HTTP header is
just a matter of specifying the header name without a header value:

    *$1p,3P,script,header=via

Generic exception filters can be used to disable specific block `header=`
filters, i.e. `@@*$1p,3P,script,header` will override the block `header=`
filters given as example above.

Dynamic filtering's `allow` rules override block `headers=` filters.

Important: It is key that filter authors use as many narrowing filter options
as possible when using the `header=` option, and the `header=` option should
be used ONLY when other filter options are not sufficient.

More documentation justifying the purpose of `header=` option will be
provided eventually if ever it is decided to move it from experimental to
stable status.

To be decided: to restrict usage of this filter option to only uBO's own
filter lists or "My filters".

Changes
=======

Fine tuning `queryprune=`
-------------------------

The following changes have been implemented:

The special value `*` (i.e. `queryprune=*`) means "remove all query
parameters".

If the `queryprune=` value is made only of alphanumeric characters
(including `_`), the value will be internally converted to regex  equivalent
`^value=`. This ensures a better future compatibility with AdGuard's
`removeparam=`.

If the `queryprune=` value starts with `!`, the test will be inverted. This
can be used to remove all query parameters EXCEPT those who match the
specified value.

Other
-----

The legacy code to test for spurious CSP reports has been removed. This
is no longer an issue ever since uBO redirects to local resources through
web accessible resources.

Notes
=====

The following new and recently added filter options are not compatible with
Chromium's manifest v3 changes:

- `queryprune=`
- `1P`
- `3P`
- `header=`
2020-11-23 08:22:43 -05:00
Raymond Hill
daf464b3c3
Add support to auto-complete values of domain lists
The auto-complete feature in the _"My filters"_ pane will
use hostname/domain from the set of opened tabs to assist
in entering values for `domain=` option. This also works
for the implict `domain=` option ṗrepending static extended
filters.
2020-11-21 09:57:54 -05:00
Raymond Hill
8d3c4916b0
Skip trying to find effective context for about:srcdoc frames
`about:srcdoc` frames are their own origin, trying to
use the origin of the parent context causes an
exception to be thrown when accessing location.href.
2020-11-21 09:51:14 -05:00
Raymond Hill
13f6bdae37
Improve representation of modifier filters in logger
As per feedback from filter list maintainers.
2020-11-20 07:14:02 -05:00
Raymond Hill
ab98cd46b1
Bring back action/state highlighting in _"My rules"_ 2020-11-20 05:34:56 -05:00
Raymond Hill
b1c55b3de9
Emphasize entity portion of hostnames in _"My rules"_ 2020-11-19 11:33:09 -05:00
Raymond Hill
38cecddcd1
Improve zapper's detection of scroll-locked documents 2020-11-18 14:11:36 -05:00
Raymond Hill
ee2fd45f00
Ensure we do not extract truncated URL for Homepage directive
Related feedback:
- b12e0e05ea (commitcomment-44309540)
2020-11-18 12:14:23 -05:00
Raymond Hill
b12e0e05ea
Extract Homepage URL from a list when present
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1346

Additionally, fixed a case of filter list being compiled
twice at subscription time.
2020-11-18 10:02:22 -05:00
Raymond Hill
d87a3b950f
Sort on base domains rather than TLDs in "My rules" pane
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1293
2020-11-18 08:01:00 -05:00
Raymond Hill
a683297931
Fix type assignment in logger page
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1349
2020-11-17 11:18:59 -05:00
Raymond Hill
e360e90d1e
Fix invalid support URL in document-blocked page
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1345
2020-11-15 10:19:09 -05:00
Raymond Hill
46d7f8a70c
Fine tune click-to-load widget
Notably, add clickable link to open the widget
in its own tab. Also, allows the URL to be text-
selected so that it becomes possible to use the
selection in a browser contextual menu's "Open
in a new tab" option.
2020-11-14 08:34:47 -05:00
Raymond Hill
5cf9bcf27c
Fine tune code of optimizeOriginHitTests()
Related commit:
- b265f2644d
2020-11-14 07:28:51 -05:00
Raymond Hill
4afb3dc149
Allow domain= with entity values into pre-test buckets
Related commit:
- b265f2644d

Filters which have `domain=` option with an entity
value will no longer be prevented from joining
pre-test buckets.
2020-11-14 07:04:21 -05:00
Raymond Hill
56cd238ad4
Disable auto activation of dark theme in next release
Until a fully usable dark theme is available. uBO's
incomplete dark theme can still be forced by setting
advanced setting `uiTheme` to `dark`.
2020-11-13 12:15:29 -05:00
Raymond Hill
eb8433cb19
Enable cloud storage compression by default in next release
Related commit:
- d8b6b31eca
2020-11-13 12:14:06 -05:00
Raymond Hill
2cfeaddbed
Fine tune various static filtering code
Notably, make `queryprune` option available only
to filter list authors, until there are guards
against bad filters in some future and until the
option syntax and behavior is fully settled.

Instances of `queryprune` in filter lists will be
compiled, however instances of `queryprune` in
_"My filters"_ will be ignored unless users
indicated they are a filter list author.
2020-11-13 09:23:25 -05:00
Raymond Hill
525d7b1b3b
Fine tune port connection code
Related commit:
- a223031b98
2020-11-13 08:32:51 -05:00
Raymond Hill
02b4d149e3
Do not skip querypruning when no-strict-blocking is true
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1341
2020-11-13 08:30:43 -05:00
Raymond Hill
a223031b98
Work around Firefox's data: favIconUrl leak
Related issue:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1652925
2020-11-12 12:14:59 -05:00
Raymond Hill
280dd8ddd6
Fix picker use of extraneous body in suggested filter
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/jregqx/
2020-11-11 09:39:07 -05:00
Raymond Hill
cfb050f521
Detect bad queryprune values
`queryprune=` values are used as literal regex
value after converting leading/trailing `|` into
`^`/`$`.
2020-11-11 08:15:39 -05:00
Raymond Hill
8cc3779fb3
Last commit changes compiled format 2020-11-11 08:15:27 -05:00
Raymond Hill
0e851c035e
Revisit realm & action bits
The important bit is now considered an action bit
so that there is no more a need for the `important`
property in the parser. The modify bit is now
considered a realm bit.

When the modify bit is set, the action bits become
available to be used to further narrow the realm.
This could be useful in the future if we want to
spread the population of modifier filters across
different buckets.
2020-11-11 07:53:46 -05:00
Raymond Hill
32eca67154
Reuse one instance of domain option iterator
Reusing the same iterator instance for all cases
of `domain=` option parsing should reduce memory
churning.

Additonally, fine tune regex used to extract
valid token from regex-based filters to increase
likelihood of being able to extract a valid
token.
2020-11-10 12:49:46 -05:00
Raymond Hill
8985376b00
Fix timing issue with cached redirection to web accessible resources
Reported internally by @gwarser.

In rare occasion, a timing issue could cause uBO to redirect
to a web accessible resource meant to be used for another
network request. This is a regression introduced with the
following commit:

- 2e5d32e967

Additionally, I identified another issue which would cause
cached redirection to fail when a cache entry with redirection
to a web accessible resource was being reused, an issue which
could especially affect pages which are generated dynamically
(i.e. without full page reload).
2020-11-10 10:43:26 -05:00
Raymond Hill
76ef4811a3
Fix queryprune for tabless requests
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/760#issuecomment-724693549
2020-11-10 08:58:39 -05:00
Raymond Hill
0196993828
Use buffer-like approach for filterUnits array
filterUnits is now treated as a buffer which is
pre-allocated and which will grow in chunks so as
to minimize memory allocations. Entries are never
released, just null-ed.

Additionally, move urlTokenizer into the static
network filtering engine, since it's not used
anywhere else.
2020-11-09 06:54:51 -05:00
Raymond Hill
db4f02199d
Convert filterSequences into a const variable
Making filterSequences constant allows to no longer
mind how the array is accessed in loops.
2020-11-08 16:00:24 -05:00
Raymond Hill
50da6706a4
Code review of static network filtering engine
- Convert this.categories Map() into an array;

- Fix case of potentially using an invalid UintArray32
  (regression from latest changes)
2020-11-08 13:50:36 -05:00
Raymond Hill
96bfe3c9a7
Convert filterUnits into a const variable
Making filterUnits constant allows to no longer
mind how the array is accessed in loops.
2020-11-08 10:30:47 -05:00
Raymond Hill
cb91d167d1
Fine tune static network filtering engine code
Notably, defer the post-load optimization operations
to a few seconds after the filters have been all
loaded in memory -- this is not a critical step for
the filtering engine to work properly, hence this
can be delayed in order to ensure readiness as soon
as possible.
2020-11-07 13:25:01 -05:00
Raymond Hill
efea83a825
Incrementally improve static filtering parser
Most notably, the `denyallow=` option now requires
the presence of a valid `domain=` option to not be
rejected.

Using `denyallow=` without narrowing down using the
`domain=` option leads to catastrophic blocking
behvior, hence the requirement for a valid `domain=`
option.
2020-11-07 13:20:02 -05:00
Raymond Hill
1d679143d2
Enable origin-hit coalescing optimisation for modifier filters
Related commit:
- b265f2644d

The optimization in the commit above was meant to
improve the performance of lookup operations of
modifier filters, but I forgot to enable the
optimisation for that class of filters.

This means this commit brings another significant
performance gain on top of the previous commit, as
shown by the built-in benchmark.

Additionally a few minor code rearrangements.
2020-11-06 18:24:46 -05:00
Raymond Hill
b265f2644d
Coallesce origin hit filters into their own bucket
Performance-related work.

There is a fair number of filters which can't be tokenized
in uBO's own filter lists. Majority of those filters also
declare a `domain=` option, examples:

    *$script,redirect-rule=noopjs,domain=...
    *$script,3p,domain=...,denyallow=...
    *$frame,3p,domain=...

Such filters can be found in uBO's asset viewer using the
following search expression:

    /^\*?\$[^\n]*?domain=/

Some filter buckets will contain many of those filters, for
instance one of the bucket holding untokenizable `redirect=`
filters has over 170 entries, which must be all visited when
collating all matching `redirect=` filters.

When a bucket contains many such filters, I found that it's
worth to extract all the non-negated hostname values from
`domain=` options into a single hntrie and perform a pre-test
at match() time to find out whether the current origin of a
network request matches any one of the collected hostnames,
so as to avoid iterating through all the filters.

Since there is rarely a match() for vast majority of network
requests with `domain=` option, this pre-test saves a good
amount of work, and this is measurable with the built-in
benchmark.
2020-11-06 12:04:03 -05:00
Raymond Hill
19331f1ab5
Fine tune latest changes for performance
Related commits:
- 157cef6034
- 1e2eb037e5
2020-11-04 07:50:51 -05:00