Commit graph

1810 commits

Author SHA1 Message Date
Raymond Hill
93f438f55e
Add advanced setting for extension reload on update
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/717

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/717#issuecomment-530275655

New advanced setting: `extensionUpdateForceReload`

Default value: `false`

If set to `true`, the extension will unconditionally reload
when an update is available; otherwise the extension will
reload only when being explicitly disabled then enabled, or
when the browser is restarted.
2019-09-11 08:00:55 -04:00
Raymond Hill
1e7e6f86a6
Reuse existing Set/Map when calling scriptletFilteringEngine.retrieve
Reuse permanent instances instead. The trailing `$` is
used to denote these variables are register-like
instances, i.e. their content is valid only for the
duration of the call. (From now on I will use this
convention throughout the code base.)
2019-09-10 13:59:28 -04:00
Raymond Hill
a73dd0a9f2
Fix entity-based lookup in html & scriptlet filtering
Entity-based filters where not properly looked-up if
they used subdomains. Example:

- `example.*##^script` => ok

- `www.example.*##^script` => failed on `https://www.example.com/`
2019-09-10 10:51:34 -04:00
Raymond Hill
4792e0e291
Coalesce tab reloads in burst "relax blocking mode" ops
Quickly firing "Relax blocking mode" commands will
cause the tab to reload only once.
2019-09-08 12:52:28 -04:00
Raymond Hill
3eeaba45d9
Cherry-picked ac7825c789 2019-09-07 08:31:32 -04:00
Raymond Hill
c8c2e11d09
Prevent reload if updated version is higher than current
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/717

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/717#issuecomment-528921730
2019-09-06 13:03:06 -04:00
Raymond Hill
bcf5ac1fee
Add advanced setting to control logger popup type
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/663

The advanced setting `loggerPopupType` has been added, to
control the type of window to be used when the logger is
launched as a separate window.

The default value is `popup`, it can be changed to any of
the values documented at:

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/windows/CreateType
2019-09-06 11:41:07 -04:00
Raymond Hill
aee6b2d1cb
Fix regression in filter compilation in element picker
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/715

Regression from fix to issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/710
2019-09-02 08:43:49 -04:00
Raymond Hill
ca9b29c7ec
Distinguish between priviledge and unprivileged messages
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/710

Messages from unprivileged ports (i.e. from content scripts)
are no longer relayed to message handlers which are to be
strictly used to execute privileged code.

The last remaining case of unprivileged messages which
should be converted into a privileged ones will be taken
care of when the following issue is fixed:
- https://github.com/gorhill/uBlock/issues/3497
2019-09-01 12:43:12 -04:00
Raymond Hill
1d805fb9da
Add support for !#if false in list directive processor
To more easily comment out blocks of filters.
2019-08-25 09:08:41 -04:00
Raymond Hill
e0b8cf24d1
Clear internal cache when loading redirect rules
Related commit:
- 3e5c9e00ab

This fix a regression: newly added redirect rules
could end up not being taken into account unless
uBO was restarted.
2019-08-24 13:48:50 -04:00
Raymond Hill
9f7e385a5c
Code review fix re. max string length in bidi-trie
Related commit:
- fb4e94f92c

A bidi-trie can't store strings longer than 255 characters
because the string segment lengths are encoded into a single
byte. This commit ensures only strings smaller than
256 characters are stored in the bidi-tries.
2019-08-23 11:30:10 -04:00
Raymond Hill
fb4e94f92c
Fix spurious 256-char limit for filters stored in bidi-trie
Plain filters can be any length, while the bidi-trie was
assuming max length of 256. The origin of this error
is from when the bidi-trie code was originally imported
from the hntrie code as start to develop bidi-trie.

The erroneous code could cause issue when the following
conditions were met:
- Plain filter longer than 256 characters
- Free space in bidi-trie's character buffer was less
  than 256 bytes

Likely a rare occurrence, but some filter lists do contains
long plain filters, for example:

    https://gitlab.com/curben/urlhaus-filter/raw/master/urlhaus-filter.txt

Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/cs1y26/
2019-08-22 17:11:49 -04:00
Raymond Hill
708e5004e8
Fix badly computed output size in µBlock.base64.encode()
This bug could cause losing 1 to 3 bytes of information
dropped from various internal buffers at encoding time.

Possibly related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/cs1y26/
2019-08-22 09:17:19 -04:00
Raymond Hill
5ad809c07d
Code review color badge code
Related commit:
- 07c950f1e5

Cache [blocking mode, color] pair for fast
lookup in subsequent calls.
2019-08-19 09:00:53 -04:00
Raymond Hill
bf3c92574e
Add support for special exception filter #@#+js()
The purpose is to wholly disable scriptlet injection
for a given site without having to create exceptions
for all matching scriptlet injection filters.

The following exception filter will cause scriptlet
injection to be wholly disable for `example.com`:

    `example.com#@#+js()`

Or to disable scriptlet injection everywhere:

    `#@#+js()`

The following form is meaningless and will be
ignored:

    `example.com##+js()`
2019-08-17 08:38:48 -04:00
Raymond Hill
6c73bd78f4
Fix regression when generating data URI in redirect engine
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/cpxm1v/

Put back erroneously removed code which enable to
generate a `data` URI from already encoded resources.
2019-08-16 13:45:07 -04:00
Raymond Hill
d67340f14d
Add ability to escape comma in a scriptlet's list of arguments
An instance of `\,` will not be interpreted as an arguments
separator -- thus allowing the use of commas inside
argument values.
2019-08-14 11:02:01 -04:00
Raymond Hill
68ae847ba3
Add support for AdGuard's mp4 filter option
Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/issues/701#issuecomment-520884196

The `mp4` filter option will be converted to `redirect=noopmp4-1s`
internally, and `media` type will be assumed.
2019-08-13 12:30:11 -04:00
Raymond Hill
52925ba2f9
Support disabling advanced setting cacheControlForFirefox1376932
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/229#issuecomment-520810161

Setting `cacheControlForFirefox1376932` to `unset` will
prevent modification of the `Cache-Control` header.
2019-08-13 08:49:37 -04:00
Raymond Hill
3e5c9e00ab
Add support for AdGuard's empty option
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/701

The filter option `empty` is converted to `redirect=empty`
by uBO internally; however unlike when the `redirect=`
option is used expressly, the `empty` option does not
require a resource type.

When `empty` is used, only network requests which are meant
to return a text response will be redirected to an empty
response body by uBO -- so `empty` will not work for
resources such as images, media, or other binary resources.
2019-08-13 08:16:21 -04:00
Raymond Hill
2c39a1af02
Extend pseudo-elements support byond ::before/::after
Related feedback:
- https://github.com/uBlockOrigin/uAssets/issues/6069#issuecomment-520254292
2019-08-11 16:32:49 -04:00
Raymond Hill
07c950f1e5
Review icon badge color management
Related commit & feedback:
- 7ff750eaf6

The color value for the icon badge is now
"attached" to the blocking profile value.
Additionally, as per feedback, `3p` rules
will be relaxing before master JavaScript
switch rules.
2019-08-11 13:55:39 -04:00
Raymond Hill
7ff750eaf6
Reflect blocking mode in badge color of toolbar icon
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/cmh910/

Additionally, the `3p` rule has been made distinct from
`3p-script`/`3p-frame` for the purpose of
"Relax blocking mode" command.

The badge color will hint at the current blocking mode.
There are four colors for the four following blocking
modes:
- JavaScript wholly disabled
- All 3rd parties blocked
- 3rd-party scripts and frames blocked
- None of the above

The default badge color will be used when JavaScript is not
wholly disabled and when there are no rules for `3p`,
`3p-script` or `3p-frame`.

A new advanced setting has been added to let the user choose
the badge colors for the various blocking modes,
`blockingProfileColors`. The value *must* be a sequence of
4 valid CSS color values that match 6 hexadecimal digits
prefixed with`#` -- anything else will be ignored.
2019-08-10 10:57:24 -04:00
Raymond Hill
5e1f4d7906
Invalidate browser's memory cache after using element picker
Related reports:
- https://www.reddit.com/r/uBlockOrigin/comments/cj7g7m/
- https://www.reddit.com/r/uBlockOrigin/comments/cnq0bi/

The browser cache will be invalidated only when creating
static network filter through the element picker.

As per @gwarser's arguments in favor of implementing
usage of webRequest.handlerBehaviorChanged():
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/handlerBehaviorChanged
2019-08-09 09:31:20 -04:00
Raymond Hill
7ac7b027f4
Restore ability to redirect xhr to image resources
The ability to redirect xmlhttprequest to binary
resources was lost when redirectable/injectable
resources became immutable in commit
152cea2dfe.

This commit restores the ability to redirect a
xmlhttprequest to a binary resource by making
it possible to derive a data: URI from the
content of binary resources such as images.

Addtionally a redirect to a data: URI can be
forced by prefixing the resource token with `%`.
This is a non-official feature at this point,
i.e. it could be removed at any time.
2019-08-06 10:51:24 -04:00
Raymond Hill
aa73f292ec
Add new static network filter option: redirect-rule=
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/310

The purpose of this new option is to add the ability
to create standalone redirect rule without being forced
to create a block filter (a corresponding block filter
is always created when using the `redirect=`).

Additionally:

The syntax `*$redirect=token,...` is now supported, there
is no need to "trick" the filter parser with
`*/*$redirect=token,...` in order to create redirect rules
which are meant to match all paths.

Filters of the form `|http*://` will be normalized into
two corresponding filters `|https://` and `|http://` so as
to reduce the number of filters in the buckets of
untokenizable filters.
2019-08-03 10:18:47 -04:00
Raymond Hill
104b222275
Revisit fix to https://github.com/uBlockOrigin/uBlock-issues/issues/627
The previous fix led to a regression. Related ffedback:
- 8d136ec2d5 (commitcomment-34460854)
2019-07-30 12:27:09 -04:00
Raymond Hill
048bfd251c
Add ability to bypass browser cache when fetching a resource
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/682#issuecomment-515197130

The following advanced setting has been added:

    updateAssetBypassBrowserCache

Default to `false`. If set to `true`, uBO will ensure the
browser cache is bypassed when fetching a remote resource.

This is for the convenience of filter list maintainers who
may want to test the latest version of their lists when
fetched from their remote location.
2019-07-26 09:52:11 -04:00
Raymond Hill
8d136ec2d5
Ignore pseudo-elements when querying selectors in element picker
Related issue:
- https://github.com/gorhill/uBlock/issues/2515
2019-07-26 09:24:34 -04:00
Raymond Hill
08c3f06160
Log :style(...) cosmetic filters only when there is a match
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/627
2019-07-23 11:42:04 -04:00
Raymond Hill
075d78e8e6
Remove trailing commas in function parameter lists
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/681
2019-07-22 17:38:23 -04:00
Raymond Hill
47cfba1551
Manually import df97249715 from 1.21.4
Related commit:
- https://github.com/gorhill/uBlock/commit/df972497156e
2019-07-22 06:30:00 -04:00
Raymond Hill
716aae4236
Reverting fix to https://github.com/gorhill/uBlock/issues/3639
Related feedback:
- a54cb2e38f (commitcomment-34387041)

Regression from converting uBO resources into
immutable resources. This affects only Chromium-based
browsers.

This is a quick fix for the dev build, to at least unbreak
the reported case.

I need to research whether the root issue (conflict with HTTPS-E)
is still occurring, and if so the fix is not trivial: I will need
to add code to uBO to fetch and convert binary data into `data:`
URIs.
2019-07-21 20:53:42 -04:00
Raymond Hill
066440534d
Prevent popup panel to close when forcing a tab reload
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/672

Additionally, this commit add the ability to press F5 to
force a reload while the popup panel is opened.
2019-07-21 11:50:15 -04:00
Raymond Hill
48347897ad
Remove obsolete ublock-resources-related code
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/679
2019-07-21 11:00:14 -04:00
Raymond Hill
e1dd7f7043
Ensure toolbar icon reflect updated whitelist directives
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/680

Opportunistically, vAPI.tabs has been refactored toward
ES6 syntax.
2019-07-21 10:48:44 -04:00
Raymond Hill
ecd81183b1
Fix thrown exception in onHeadersReceived listener
Regression from:
- https://github.com/gorhill/uBlock/commit/ae56c4dfe855
2019-07-19 10:02:27 -04:00
Raymond Hill
10fe9fe656
Allow setting assetsBootstrapLocation from admin settings
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/666
2019-07-18 10:53:08 -04:00
Raymond Hill
3b0d214633
Mind escape sequences when validating :style filters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/668
2019-07-13 07:49:07 -04:00
Raymond Hill
8d8336ffae
Remove useless return statement 2019-07-12 09:13:10 -04:00
Raymond Hill
d6927cf1fe
Ensure all members are initialized before loading selfie
Theoretically, if a selfie is loaded from corrupted
storage resulting in a thrown exception from the
constructor, this would cause an improperly initialized
HostnameBasedDB instance and overall potentially a
broken uBO.

Related feedback:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1543880#c7
2019-07-12 09:05:42 -04:00
Raymond Hill
ce644c5960
Remove code unused in next release
Since https://github.com/uBlockOrigin/uBlock-issues/issues/156
won't be fixed in next release, no need to ship
with code which will be unused, and anyways only once
the fix is worked on will it be clear exactly what needs
to be used by scriptlets to deal harmoniously with
property listener collisions.
2019-07-11 10:17:06 -04:00
Raymond Hill
9ef06da310
Minor code review re. https://github.com/uBlockOrigin/uBlock-issues/issues/658 2019-07-11 09:50:12 -04:00
Raymond Hill
874e92af2d
Fix regression in URL rules validation
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/665

Regression:
- 2f63fb3fd4
2019-07-10 17:24:01 -04:00
Raymond Hill
b54522caa1
[scriptlet engine] Mind old scriptlet names not using .js
Related commit:
- 5552d6717d
2019-07-09 11:36:42 -04:00
Raymond Hill
5c449f59f2
[redirect engine] Use shorter name as the official name
- nobab.js => bab-defuser.js
- nofab.js => fuckadblock.js-3.2.0
2019-07-09 11:04:12 -04:00
Raymond Hill
fee217c59c
Fix regression introduced in 2f63fb3fd4
Related feedback:
- 2f63fb3fd4 (commitcomment-34222571)
2019-07-08 12:33:11 -04:00
Raymond Hill
2f63fb3fd4
Prevent adding known invalid URL-based rules
Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/issues/662#issuecomment-509220702

Currently, `doc` (aka `main_frame`) rules are not
evaluated to decide whether a network request must
be blocked or not, by design. This commits adjust
uBO's UI to account for this.
2019-07-08 10:49:53 -04:00
Raymond Hill
e55cae6232
Fine tune new resources-related code
Make sure the parser is safely compatible with old
resources format -- for those users still using
custom resources (via `userResourcesLocation`).

Prepare code for future fix to
<https://github.com/uBlockOrigin/uBlock-issues/issues/156>:

This commit introduces a new private Map() object,
`uBOSafe`, accessible by all injected scriptlets. This
private safe can be used to store data which can be shared
with different scriptlets. The idea is for scriptlets to
use that safe to graciously deal with the need to install
multiple listeners for the same property.
2019-07-08 08:56:36 -04:00