1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-25 11:52:51 +01:00
Commit Graph

4754 Commits

Author SHA1 Message Date
Raymond Hill
c746633693
Validate result type of XPath expressions
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/3403

To ensure XPath expressions not meant to return a nodeset are
discarded at compile time.
2024-10-06 14:27:55 -04:00
Raymond Hill
818cb2d801
Fix npm test suite
Related commits:
- https://github.com/gorhill/uBlock/commit/02cba63331
- https://github.com/gorhill/uBlock/commit/41693407b2
2024-10-06 11:15:08 -04:00
Raymond Hill
64b2086ba4
Add ability to lookup parameter name in urlskip=
Relate case:
https://github.com/uBlockOrigin/uBlock-issues/issues/3206#issuecomment-2395121619

Newly supported step: `&i`, meant to lookup a parameter's name at
position `i` (1-based). The parameter name will be used as the
URL (whereas `?` is meant to lookup a parameter's value).
2024-10-05 14:59:43 -04:00
Raymond Hill
02cba63331
Partially revert 4169340 2024-10-05 14:51:38 -04:00
Raymond Hill
6d2b3375f8
Mind that BroadcastChannel contructor can throw in Firefox
BroadcastChannel constructor throws in Firefox when Enhanced
Tracking Protection is set to "strict".

This behavior could cause scriptlet injection to wholly break
when uBO's logger was opened, as BroadcastChannel() is used
by scriptlets to report information to the logger.

This commit ensures that exceptions from BroadcastChannel
constructor are properly handled.

The scriptlets will fall back to report at the console should
they be unable to report to the logger through BroadcastChannel.
2024-10-05 12:42:30 -04:00
Raymond Hill
41693407b2
Fix npm test suite
Ensure serialization returns copy of data rather than live
references to data. This allows to immediately deserialize() the
result of serialize().

Also, adjust code to modified behavior of filterQuery().
2024-10-05 11:32:59 -04:00
Raymond Hill
d24ffe6bb8
Import translation work from https://crowdin.com/project/ublock 2024-10-04 12:30:37 -04:00
Raymond Hill
5133991f7e
Fix spurious error in content script
No guarantee vAPI.bootstrap will still be present when callback
executes.
2024-10-04 08:57:10 -04:00
Ilya (Marshal)
9f4123a4e2
Fix AdGuard Knowledge Base URLs 2024-10-04 11:27:24 +02:00
Raymond Hill
73ce4e6bcf
Blocking large media elements also prevents autoplay, regardless of size
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/3394

When the "No large media elements" per-site switch is toggled on,
it will also act to prevent autoplay of video/audio media, regardless
of their size. This also works for xhr-based media streaming.

If blocking by size is not desirable while blocking autoplay is
desired, one can toggle on "No large media elements" switch while
setting "Block media elements larger than ..." to a very high value.
2024-10-02 13:39:36 -04:00
Raymond Hill
6cac645830
Do not discard !#else block for unknown preprocessor tokens
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/3393
2024-09-30 10:16:48 -04:00
Raymond Hill
3d6984aeaf
Import translation work from https://crowdin.com/project/ublock 2024-09-29 17:06:51 -04:00
Raymond Hill
c6baa2fb51
Import translation work from https://crowdin.com/project/ublock 2024-09-29 11:15:04 -04:00
Raymond Hill
e81e70937f
Add ability to decode base64 in urlskip=
Related case:
https://github.com/uBlockOrigin/uAssets/issues/25467

New step: `-base64`
Purpose: to decode base64-encoded output of previous step
2024-09-29 10:51:56 -04:00
Raymond Hill
99191d1363
Import translation work from https://crowdin.com/project/ublock 2024-09-28 14:12:13 -04:00
Raymond Hill
aec0bd39e3
Fix images not properly downloading on click
Related feedback:
https://github.com/uBlockOrigin/uBlock-issues/issues/1670#issuecomment-2372048056

The issue affected images supporting `srcset` attribute without
the presence of `src` attribute. This commit takes add fallback
onto `srcset` attribute when the `src` attribute is not present.
2024-09-26 13:27:06 -04:00
Raymond Hill
4c5a9353b0
Import translation work from https://crowdin.com/project/ublock 2024-09-22 11:50:20 -04:00
Raymond Hill
bd6d9c3296
Fix benchmark quirk related to new ipaddress option 2024-09-22 11:16:57 -04:00
Raymond Hill
e7c783cefa
Code review for new DNS cache code
Prevent discarding DNS cache entries looked up during a passive
read. Related feedback:
https://github.com/uBlockOrigin/uBlock-issues/discussions/3376#discussioncomment-10711948

Add advanced setting `dnsCacheTTL` to control the TLL (in
seconds) of DNS cache entries. Default to 600 (10 minutes).
2024-09-22 10:02:45 -04:00
Raymond Hill
1c97ca10fc
Minor code review
Use class fields to declare/initialize instance and static
properties.
2024-09-21 12:41:57 -04:00
Raymond Hill
055973cc3f
Import translation work from https://crowdin.com/project/ublock 2024-09-20 09:16:32 -04:00
Raymond Hill
59487b189c
Add +https directive to urlskip= option
When present, the `+https` directive will force the protocol of the
resulting URL to be `https:`.

Related feedback:
https://github.com/uBlockOrigin/uBlock-issues/issues/3206#issuecomment-2363392357
2024-09-20 08:15:31 -04:00
Raymond Hill
4f181b0bc5
Support matching against list of IP addresses
Related commit:
6acf97bf51
2024-09-20 07:20:55 -04:00
Raymond Hill
760b2ffce6
Add advanced setting dnsResolveEnabled
Default to `true`.

Set to `false` to wholly disable calls to `dns.resolve()` (Firefox-
only). Disabling calls to `dns.resolve()` will prevent cname-uncloaking
and will limit ability to enforce `ipaddress` filter option.
2024-09-19 08:43:54 -04:00
Raymond Hill
b01a418073
Add filtering output expressionsreplace/urlskip to logger
Additioanlly, removed `uritransform` as it is currently barely used,
if at all.
2024-09-19 08:08:49 -04:00
Raymond Hill
e98fdeb0a5
Mind urlskip= in built-in benchmark 2024-09-18 12:24:04 -04:00
Raymond Hill
0a6dc47a72
Fix contextual menu quirks
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/3382
2024-09-18 11:33:31 -04:00
Raymond Hill
62d74d4f1d
Add trailing wildcard syntax to ipaddress= option
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/3381
2024-09-18 09:56:46 -04:00
Raymond Hill
3238fe48db
Import translation work from https://crowdin.com/project/ublock 2024-09-17 17:48:45 -04:00
Raymond Hill
ef1e134460
Import translation work from https://crowdin.com/project/ublock 2024-09-15 13:27:32 -04:00
Raymond Hill
b62aabda85
Import translation work from https://crowdin.com/project/ublock 2024-09-15 13:25:58 -04:00
Raymond Hill
e18a3707c7
Add an entry in _Report_ page for badware/phishing category
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/3151

Entry:
"Add an entry in the reporting tool for badware issues"
2024-09-15 13:20:47 -04:00
Raymond Hill
266ec4894b
New static network filter option urlskip=
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/3206

The main purpose is to bypass URLs designed to track whether a user
visited a specific URL, typically used in click-tracking links.

The `urlskip=` option ...

- ... is valid only when used in a trusted filter list
- ... is enforced only on top documents
- ... is enforced on both blocked and non-blocked documents
- ... is a modifier, i.e. it cannot be used along with other
      modifier options in a single filter

The syntax is `urlskip=[steps]`, where steps is a space-separated
list of extraction directives detailing what action to perform on
the current URL.

The only supported directive in this first commit is `?name`,
which purpose is to extract the value of a named URL parameter
and use the result as the new URL. Example:

  ||example.com/path/to/tracker$urlskip=?url

The above filter will cause navigation to

  https://example.com/path/to/tracker?url=https://example.org/

to automatically bypass navigation to `example.com` and navigate
directly to

  https://example.org/

It is possible to recursively extract URL parameters by using
more than one directive, example:

  ||example.com/path/to/tracker$urlskip=?url ?to

More extraction capabilities may be added in the future.
2024-09-15 09:17:19 -04:00
Raymond Hill
4b285c0593
Dynamically load DNR conversion module on-demand
DNR conversion module is a dev tool, no point loading it by
default. This was done this way because in a distant past uBO
had to be compatible with browsers not supporting dynamically
loaded modules.

Currently all supported browser versions support dynamically
loaded modules.
2024-09-14 12:13:47 -04:00
Raymond Hill
c265e849e0
Fetch and cache cname of collated hostnames in page store
Related feedback:
https://github.com/uBlockOrigin/uBlock-issues/discussions/3376
2024-09-14 11:50:10 -04:00
Raymond Hill
f936dfa648
Fix potential failure to unregister scriptlet
In Firefox-specific contentScripts API used to register
scriptlets. This could potentially occurs when there are
registrations pending during a reload of filter lists.
2024-09-14 09:32:37 -04:00
Raymond Hill
41d49921c8
Minor code review 2024-09-14 09:20:54 -04:00
Raymond Hill
5e6f78a902
Fix regression re. mp4 filter option
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/3375
2024-09-14 00:10:34 -04:00
Raymond Hill
8fadfb2c5e
Import translation work from https://crowdin.com/project/ublock 2024-09-12 15:40:24 -04:00
Raymond Hill
6acf97bf51
Rewrite cname uncloaking code to account for new ipaddress= option
This commit makes the DNS resolution code better suited for both
filtering on cname and ip address. The change allows early availability
of ip address so that `ipaddress=` option can be matched at
onBeforeRequest time.

As a result, it is now possible to block root document using
`ipaddress=` option -- so long as an ip address can be extracted
before first onBeforeRequest() call.

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

Caveat
------

the ip address used is the first one among the list of ip
addresses returned by dns.resolve() method. There is no way for uBO
to know which exact ip address will be used by the browser when
sending the request, so this is at most a best guess. The exact IP
address used by the browser is available at onHeadersReceived time,
and uBO will also filter according to this value, but by then the
network request has already been sent to the remote server.

Possibly a future improvement would make available the whole list
of ip addresses to the filtering engine, but even then it's impossible
to know with certainty which ip address will ultimately be used by the
browser -- it is entirely possible that the ip address used by the
browser might not be in the list received through dns.resolve().
2024-09-12 11:19:57 -04:00
Raymond Hill
099b9852cd
Code review for ipaddress= filter option
If an IP address can be extracted from the hostname portion of
a URL, the IP address matching will be performed at onBeforeRequest()
time.

Regardless, IP address matching will subsequently always be performed
at onHeadersReceived() time as the request details at that point
contain a reliable IP address value on supported platforms (Firefox-
only as of now).

The `cap_ipaddress` now evaluates to `true` in Chromium-based
browsers. Even though these browsers are unable to provide reliable
IP address value at onHeadersReceived() time, they can still
perform IP address matching for IP address extracted from hostname
portion of a URL.
2024-09-11 09:56:44 -04:00
Raymond Hill
d5f14ffa32
Avoid using dns.resolve() for proxied DNS resolution
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/1743
2024-09-10 14:58:40 -04:00
Raymond Hill
401d2e8ea9
[mv3] Mind unsupported header=/ipaddress options in DNR API
Properly report unsupported `header=` and `ipaddress=` option in
log file.

`header=` support may become possible soon with Chromium 128
introducing blocking according to response headers content.
2024-09-10 11:50:09 -04:00
Raymond Hill
030d7334e4
Add support for lan/loopback values to ipaddress= option
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/1070
2024-09-10 11:11:11 -04:00
Raymond Hill
c6dedd253f
New static network filter option ipaddress=
The purpose is to block according to the ip address of a network
request. In the current implementation, the filter option can only
be enforced at onHeadersReceived time.

The new filter option cannot be enforced in Chromium-based browsers
since the ip address of network requests is available only at
onResponseStarted time, which is not blocking.

The value assigned to `ipaddress` can either be a plain string which
must match exactly a given ip address, or a regex which will be
matched against the ip address.

The `ipaddress` option can only be enforced when the extension
framework does provide a valid ip address in a onHeadersReceived
listener. For instance, cached resources do not have a valid ip
address and thus can't be a match to `ipaddress` option.

Example:

  *$script,ipaddress=93.184.215.14
2024-09-09 09:35:23 -04:00
Raymond Hill
20115697e5
Add ability to quote static network option values
For the sake of convenience for filter list maintainers, this commit
add ability to quote static network option values, so as to avoid the
need to escape commas when parser ambiguity arises.

The quotes can be `"`, `'`, or backticks.

Example, the following filter requires escaping commas:

  example.com$xhr,replace=/"loremIpsum.*?([A-Z]"\}|"\}{2\,4})\}\]\,//,1p

Can be now rewritten with no need to escape when using quotes:

  example.com$xhr,replace='/"loremIpsum.*?([A-Z]"\}|"\}{2,4})\}\],//',1p
2024-09-08 10:01:13 -04:00
Raymond Hill
89f02098fd
Apply CSP/PP injections to object resources
Related feedback:
https://old.reddit.com/r/uBlockOrigin/comments/1f84tc5/
2024-09-04 11:28:45 -04:00
Raymond Hill
91125d29cf
Add support for application/dash+xml in replace= option
Related feedback:
https://github.com/uBlockOrigin/uAssets/issues/25164#issuecomment-2326358453
2024-09-03 10:14:15 -04:00
Raymond Hill
b7ed3b45ed
Add ability to directly evaluate static network filtering engine
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/3362

There used to be a way to test URL against the network filtering engine,
but this was removed in a distant past during refactoring.

The ability has been brought back through uBO's own developer tools,
accessible through the _More_ button in the _Support_ pane in the
dashboard.

To query the static network filtering engine, enter the following
in the text editor:

snfe?url-to-test [type] [url-of-context]

`snfe?` is a prompt indicating the intent to query the static network
filtering engine.

At a minimum there must be a URL to test.

Optionally the type of the resource to match, default to `xhr` if
none specified. Also optionally, the context from within which the
request is made. Example:

Enter:
snfe?https://www.google-analytics.com/analytics.js

Result:
url: https://www.google-analytics.com/analytics.js
blocked: ||google-analytics.com^

Enter:
snfe?https://www.google-analytics.com/analytics.js script

Result:
url: https://www.google-analytics.com/analytics.js
type: script
blocked: ||google-analytics.com^
modified: ||google-analytics.com/analytics.js$script,redirect-rule=google-analytics_analytics.js:5

Enter:
snfe?https://example.com/

Result:
url: https://example.com/
not blocked

Enter:
snfe?https://example.com/ ping

Result:
url: https://example.com/
type: ping
blocked: *$ping,3p
2024-09-02 19:32:56 -04:00
Raymond Hill
59a9a43a83
Add noop resources for redirect purpose
Related discussion:
https://github.com/uBlockOrigin/uAssets/issues/25014#issuecomment-2307982886
2024-08-24 12:11:35 -04:00