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

2259 Commits

Author SHA1 Message Date
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