Commit graph

2003 commits

Author SHA1 Message Date
Raymond Hill
453f5450b6
First pass to Re-design the dashboard
This is a first pass in which only the dashboard
navigation widget and the "Settings" pane have
been revisited.

Reference work:
- https://app.abstract.com/share/54f1465e-8d1c-4e7b-9ae4-f37e21bef7fe
2020-04-05 15:19:07 -04:00
Raymond Hill
20332c65b4
No need for "Shortcuts" pane in Firefox 74 and above
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/386
2020-04-05 09:47:22 -04:00
Raymond Hill
df08b12d48
Fix race condition at browser launch re. cosmetic filtering
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/974

Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/fuscia/

The race condition was that a content script could
query the main process to retrieve cosmetic filters
while the cosmetic filters had not been yet fully
loaded into memory. The fix ensure that an already
injected content script will re-query once the
cosmetic filters are fully loaded in memory at
browser launch time.
2020-04-04 11:34:43 -04:00
Raymond Hill
1295e25961
Remove unused property 2020-04-03 09:07:22 -04:00
Raymond Hill
044a1dd6ee
Fix :style exception filters not being reported in logger
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/962

Regression from:
- 72bb700568
2020-03-26 09:19:02 -04:00
Raymond Hill
2f927847f2
Discard :style() filters chained to procedural operators
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/961
2020-03-26 08:38:22 -04:00
Raymond Hill
11d24abea0
Move proxy-detection code to Firefox-specific code
Related commit:
- https://github.com/uBlockOrigin/uBlock-issues/issues/911

The motivation is to avoid executing code which is
unnecessary on platforms not supporting the browser.dns
API.
2020-03-23 13:31:43 -04:00
Raymond Hill
0c30bee3e3
Fix typo in proxy-detecting code
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/911

Related commit:
- https://github.com/gorhill/uBlock/commit/3f7ece94691f
2020-03-23 12:23:05 -04:00
Raymond Hill
3f7ece9469
Do not cname-uncloak when a proxy is in use
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/911

Since cname-uncloaking is available only on Firefox
at the moment, the fix is relevant only to Firefox.

By default uBO will no longer cname-uncloak when it
detects that network requests are being being proxied.

This default behavior can be overriden by setting the
new advanced setting `cnameUncloakProxied` to `true`.
The new setting default to `false`, i.e. cname-uncloaking
is disabled when uBO detects that a proxy is in use.

This new advanced setting may disappear once the
following Firefox issue is fixed:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1618271
2020-03-22 14:52:58 -04:00
Raymond Hill
f5204235b7
Use prime number to generate cache-bypass token
Related discussion:
- https://github.com/gorhill/uBlock/commit/048bfd251c9b#r37972005

From <https://github.com/gwarser>:

> I think this should be "modulo prime", not 12.
> If someone always turn on PC in "8am" there is
> a slight chance to hit cache.
2020-03-22 11:31:06 -04:00
Raymond Hill
381498daa2
Reorganize filter instances deduplication code
Related commit:
- https://github.com/gorhill/uBlock/commit/ab629b9e1093
2020-03-19 13:42:06 -04:00
Raymond Hill
a36566b348
Allow empty needle in BidiTrieContainer.lastIndexOf()
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/882

Related commit:
- https://github.com/gorhill/uBlock/commit/7c0294bd5f54

The changes in the commit above have been reverted, and
the new fix is to add the ability to handle an empty
needle in BidiTrieContainer.lastIndexOf() -- in which
case the method will return the end of the currently
matched pattern.
2020-03-19 13:16:41 -04:00
Raymond Hill
ab629b9e10
Add filter instance deduplicater in static net filtering engine
Provide a way to optionally deduplicate filter
instances, useful for filter instances with:

- high likelihood of duplication; and
- non-trivial memory footprint per instance
  - For examples, filter instances to implement
    `domain=`, `denyallow=`, `csp=`.

Cursory tests show this helps further reduce
uBO's memory footprint.
2020-03-18 09:06:33 -04:00
Raymond Hill
c3bc2c741d
Add support for cname type and denyallow option
This concerns the static network filtering engine.

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

* * *

New static network filter type: `cname`

By default, network requests which are result of
resolving a canonical name are subject to filtering.
This filtering can be bypassed by creating exception
filters using the `cname` option. For example:

    @@*$cname

The filter above tells the network filtering engine
to except network requests which fulfill all the
following conditions:

- network request is blocked
- network request is that of an unaliased hostname

Filter list authors are discouraged from using
exception filters of `cname` type, unless there no
other practical solution such that maintenance
burden become the greater issue. Of course, such
exception filters should be as narrow as possible,
i.e. apply to specific domain, etc.

* * *

New static network filter option: `denyallow`

The purpose of `denyallow` is bring
default-deny/allow-exceptionally ability into static
network filtering arsenal. Example of usage:

    *$3p,script, \
        denyallow=x.com|y.com \
        domain=a.com|b.com

The above filter tells the network filtering engine that
when the context is `a.com` or `b.com`, block all
3rd-party scripts except those from `x.com` and `y.com`.

Essentially, the new `denyallow` option makes it easier
to implement default-deny/allow-exceptionally in static
filter lists, whereas before this had to be done with
unwieldy regular expressions[1], or through the mix of
broadly blocking filters along with exception filters[2].

[1] https://hg.adblockplus.org/ruadlist/rev/f362910bc9a0

[2] Typically filters which pattern are of the
    form `|http*://`
2020-03-15 12:23:25 -04:00
Raymond Hill
bc700e691c
Fix srcset handling in element picker
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/923

Use current page's hostname instead of that of
image URLs to decide whether to reset pattern
union with previous picker sessions.

The fixed issue arose from the fact that the
page uses URLs from different origins in a
single srcset attribute.
2020-03-15 08:45:17 -04:00
Raymond Hill
ca80d2826b
Add indentation requirement for line continuation
Related commit:
- https://github.com/gorhill/uBlock/commit/703c525b01aa

This adds an indentation requirement for line
continuation to take place. The conditions are now
as follow:
- Current line ends with ` \`: ASCII space + backslash
- Next line starts with `    `: four ASCII spaces
2020-03-15 08:15:17 -04:00
Raymond Hill
703c525b01
Support line continuation in filter lists
If a line in a filter list ends with a space
(ASCII code 32) followed by a backslash
(ASCII code 92), those two characters will be
removed, the line will be trimmed and the next
line will be trimmed and concatenated to form
a new, longer line.

The purpose is to give filter list authors
a way to visually break apart unduly long
filters and thus make maintenance easier.

When line continuation is used, it is suggested
that the extra lines are prepended with four
space so as to make it more visually obvious that
the extra line(s) are the continuation of a
previous line.

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

The filter referenced in the above issue was the
motivation to implement this feature:
- https://hg.adblockplus.org/ruadlist/rev/f362910bc9a0

I verified and could not find any instance in major
filter lists of lines ending with ` \`, thus the
change should be safe.
2020-03-14 13:34:13 -04:00
Raymond Hill
2cbbc30084
Also remove text node in :remove() operator
Related discussion:
- https://github.com/gorhill/uBO-Extra/issues/119#issuecomment-537842967

As an incidental side effect, this may or may not
prevent execution of the content of some inline
script tags.
2020-03-09 11:34:49 -04:00
Raymond Hill
1d9421b8b2
Improve validation of CSS selector-based cosmetic filters
Reported internally. The following invalid filter was not
discarded by uBO:

    123tvnow.com##.123tv-ads

The correct form should be:

    123tvnow.com##.\31 23tv-ads

Not discarding invalid CSS selector-based cosmetic
filter may break CSS selector-based cosmetic
filtering.
2020-03-08 10:55:19 -04:00
Raymond Hill
72bb700568
Add procedural cosmetic operators remove() and upward()
***

New procedural cosmetic operator: `:remove()`

Related issue:
- https://github.com/gorhill/uBlock/issues/2252

The purpose is to outright remove elements from the
DOM tree. Since `:remove()` is an "action" operator,
it must only be used as a trailing operator (just
like the `:style()` operator).

AdGuard's cosmetic filter syntax `{ remove: true; }`
will be converted to uBO's `:remove()` operator
internally.

***

New procedural cosmetic operator: `:upward(...)`

The purpose is to lookup an ancestor element.

When used with an integer argument, it is synonym of
`:nth-ancestor()`, which will be deprecated and which
will no longer be supported once no longer used in
mainstream filter lists.

Filter lists maintainers must only use `:upward(int)`
instead of `:nth-ancestor(int)` once the new operator
become available in all stable releases of uBO.

`:upward()` can also accept a CSS selector as argument,
in which case the nearest ancestor which matches the
CSS selector will be selected.
2020-03-07 14:25:06 -05:00
Raymond Hill
bef9eedf73
Support hidden hyphen HTML entity in translation work
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/907#issuecomment-590804054
2020-03-02 12:34:50 -05:00
Rory O’Kane
be111c4036
In Element Zapper, support Mac keyboards’ Delete key (#3770)
Override the Backspace key, not just the Delete key, as Mac keyboards have Backspace as the only delete key and label it Delete.

Source of key value: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values#Editing_keys

More background on Mac keyboard shortcuts: Mac keyboards can emulate Delete using fn+Delete, meaning Forward Delete, but Mac software does not use it except in text editing. When deletion is dangerous, Mac software requires holding a modifier key in conjuction with Delete, but I think it’s better to make deletion easy in this case.

This new binding has a potential downside: if the user Backspace key normally goes Back in history (which can differ across OSs and browsers), this will change the behavior to delete the selected element instead. If the user really wants to go back in history, they will have to press Escape to leave the mode and then press Backspace, or they will have to press an alternative keyboard shortcuts such as Alt+Left. I think the user will rarely want to go back in history in the middle of picking an element, though.

That downside could be mitigated by conditioning the key check on `runtime.PlatformOs` (https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/PlatformOs). But that would complicate the code a lot compared to the importance of this feature, and such detection would still fail to capture the user’s intent accurately in all cases. I think it’s better to unconditionally accept both Backspace (Delete) and Delete (Forward Delete).
2020-02-28 14:28:00 -05:00
Raymond Hill
da71c3a499
Force console output when explicitly requested from dev tools
Related feedback:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1617666#c0

Not being able to see benchmark results when explicitly
requesting benchmark results is not very user-friendly;
this commit fixes this.
2020-02-25 11:00:58 -05:00
Raymond Hill
c17a9c8a93
Fix spurious warning when force-reloading the dashboard
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/905

Additionally, minor changes to avoid spurious errors in
browser console.
2020-02-24 09:59:35 -05:00
Raymond Hill
7634604aa8
Make element picker mind that network filters are case-insensitive
Related discussion:
- https://github.com/easylist/easylist/pull/4950#issuecomment-590064744
2020-02-24 09:24:54 -05:00
Raymond Hill
3621792f16
Rework/remove remnant of code dependent on localStorage
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/899
2020-02-23 12:18:45 -05:00
Raymond Hill
d16ac963ef
Use correct element id fenix popup panel 2020-02-23 12:16:50 -05:00
Raymond Hill
15470bcbdc
Ensure disableWebAssembly setting is loaded before use
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/899

WASM modules are now loaded on demand rather than at
script evaluation time.
2020-02-22 13:36:22 -05:00
Raymond Hill
2ac288397c
Remove usage of synchronous localStorage API
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/899

browser.storage.local is now used to store non-critical
local settings.

These settings are all collated under the key
`localStorage`, and vAPI.localStorage is an API to
handle access to these values stored under this key.

vAPI.localStorage.getItem() is still synchronous but
its purpose is to return internally cached values --
this minimizes code changes throughout uBO.
2020-02-21 15:34:54 -05:00
Raymond Hill
5da3aaaabf
Properly test for WebAssembly presence before use
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/900
2020-02-21 15:21:25 -05:00
Raymond Hill
ddc2b11657
Fail graciously if no benchmark dataset found 2020-02-21 08:13:15 -05:00
Raymond Hill
b784b7d569
Support loading of benchmark dataset in published versions
New advanced setting: `benchmarkDatasetURL`
Default value: `unset`

To specify a URL from where the benchmark dataset will be
fetched. This allows to launch benchmark operations from
within published versions of uBO, rather than from just
a locally built version.
2020-02-21 08:06:52 -05:00
Raymond Hill
5ccf435754
Add edge-scheme to default whitelist directives
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/879
2020-02-20 16:43:56 -05:00
Raymond Hill
da0ef9454a
Neutralize localStorage access on mobile platform
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/899

window.localStorage is synchronous and thus should be
avoided at launch time. Currently the avoidance is only
for mobile platforms.
2020-02-20 16:40:29 -05:00
Raymond Hill
69a7c6771b
Fine tune fenix UI as per Bram's feedback 2020-02-18 09:53:20 -05:00
Raymond Hill
3fab7bfdb4
Add support for "specific-generic" cosmetic filters
A specific cosmetic filter of the following form...

    *##.selector

... will be unconditionally injected into all web pages,
whereas a cosmetic filter of the form...

    ##.selector

... would be injected only when uBO's DOM surveyor finds
at least one matching element in a web page.

The new specific-generic form will also be disabled when a
web page is subject to a `generichide` exception filter,
since the filter is essentially a generic one -- the only
difference from the usual generic form is that the filter
is injected unconditionally instead of through the DOM
surveyor.

Specific-generic cosmetic filters will NOT be discarded
when checking the "Ignore generic cosmetic filters"
option in the "Filter lists" pane -- since the purpose
of this option is primarily to disable the DOM surveyor.

Specific-generic cosmetic filters should be used
parcimoniously and only when using a normal specific
filter is really impractical.

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/803
2020-02-14 11:51:05 -05:00
Raymond Hill
8adad98a0d
New way to convey IDN and CNAME info in popup panel
Hostnames which have unpunycoded IDN or canonical
name information will have this information reported
as an extra line under the hostname name in the popup
panel, rather than as a tooltip.

For the fenix UI flavor, the save/revert tools are
now shown regardless of whether the overview area is
visible or not.
2020-02-10 08:06:36 -05:00
JustOff
a806dd4bd2
Add env_legacy to the pre-processor supported tokens (#3768)
This will allow specifically target uBlock Origin for Firefox legacy-based browsers in shared filter lists,
see https://github.com/gorhill/uBlock-for-firefox-legacy/pull/1.
2020-02-09 08:23:00 -05:00
Raymond Hill
760d206bd4
Select default UI according to target platform
More specifically, this commit makes it so that
the new default UI for Firefox Preview will be
automatically selected.

A default platform-specific UI can be cancelled
by setting the advanced setting `uiFlavor` to `-`.
2020-02-06 11:42:12 -05:00
Raymond Hill
4509483c7e
Set tooltip to cname alias in popup panel
The toolip of a canonical name entry (blue)
in the popup panel will provide the alias
hostname related to the canonical hostname
in order to help with rule-making decisions.
2020-02-06 10:18:15 -05:00
Raymond Hill
651955b97c
Throw if mismatched size when unserializing an array buffer
An exception will be thrown if the length of an unserialized
array buffer does not match exactly the original size at
serialization time.
2020-02-04 09:55:02 -05:00
Raymond Hill
609e9a6428
Remove elision of leading wildcard in some filter patterns
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/882

Related commits:
- https://github.com/gorhill/uBlock/commit/a95ef16e064a
- https://github.com/gorhill/uBlock/commit/7971b223855d

Leading wildcards before valid token characters need to
be kept in order to respect the semantic of the filter.
A leading wildcard in such case changes the semantic of
a filter, i.e. two following filters are semantically
different:

    example/abc
    *example/abc

As a result, µBlock.BidiTrieContainer.indexOf() is now
able to deal with a needle of length zero -- which is
what happens in FilterPatternLeft(Ex) with filter
patterns starting with `*` (or `^*`) and followed by
valid token characters (0-9, a-z and %).
2020-02-03 14:09:37 -05:00
Raymond Hill
a95ef16e06
Fix token position value when removing leading wildcard
Related issue:
- https://www.reddit.com/r/uBlockOrigin/comments/ex8ggg/

Regression from:
- https://github.com/gorhill/uBlock/commit/7971b223855d
2020-02-02 10:05:15 -05:00
Raymond Hill
1d51927d2e
Fix handling of end-anchor in redirect patterns
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/872

An end-anchor was treated as literal `|` in the redirect
pattern to match instead of as a end-of-string condition.
2020-02-01 12:47:17 -05:00
Raymond Hill
0627fcfb62
Fix broken row rendering for non-network-based URL
Reported internally by volunteers.

Regression from:
- https://github.com/gorhill/uBlock/commit/3a564c199260#diff-fd76b4e8f9d7bfb2e5e01510c9457633L367
2020-01-31 13:48:17 -05:00
Raymond Hill
fcc7781aef
Use proper popup URL 2020-01-30 12:43:41 -05:00
Raymond Hill
2b0316440e
First draft of popup panel for Firefox Preview
First draft of changes as discussed with Firefox
Preview people.

In order to allow testing/evaluating these changes,
the new advanced setting `uiFlavor` has been added.
Default to `unset`; and can currently only be set
to `fenix`.

The new setting takes effect at launch only. This
new setting is not to be mentioned in official
documentation for now.

This is ongoing work, not open to external feedback.
2020-01-25 09:24:59 -05:00
Raymond Hill
2e0a8951b8
Minor code review 2020-01-23 12:06:40 -05:00
Raymond Hill
043ae117c8
Decouple error handling of lists loading from selfie loading
This commit make it so that if an *unexpected* error is
thrown when trying to load the selfie at launch, the filter
lists will still be loaded as a result.
2020-01-21 10:52:13 -05:00
Raymond Hill
f8ec54c635
Fix compatibility issue with hosts files
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/847

IP address `0` is a valid synonym of `0.0.0.0`.
2020-01-10 11:07:31 -05:00
Raymond Hill
8704e4e620
Improve token extraction from regex-based filters
Tokens which are as long or longer than the max token
length possible do not need to have the prefix part
evaluated against special regex characters. This will
help increase the likelihood of extracting a valid
token from regex-based filters.

Actual case found in EasyPrivacy:

  /^https?:\/\/eulerian..*\/[a-z0-9]{2,12}\.js/$script

Before this commit, uBO was not able to extract a
valid token, while now uBO is able to extract `eulerian`
as a valid token (consequently the regex-based filter
will now be evaluated only when the token `euleria` is
found in a URL).
2020-01-09 10:09:51 -05:00
Raymond Hill
2cf79ef922
Minor code review 2020-01-04 09:32:28 -05:00
Raymond Hill
d0738c0835
Visually distinguish canonical names in popup panel
Further fine-tuning support for canonical names.

Aliased canonical names will be rendered blue
in the dynamic filtering pane of the popup panel.
2019-12-31 16:36:51 -05:00
Raymond Hill
e9abce61a0
Fix unescaped attr value in generated CSS selector
Related feedback:
- https://github.com/NanoAdblocker/NanoCore2/commit/5e625da8fe45#commitcomment-36625096
2019-12-31 16:14:50 -05:00
Raymond Hill
56cc2b1256
Support expanding/collpasing of specific domains
This is related to the list of domains/subdomains in
the dynamic filtering pane of the popup panel.

Related issue:
- https://github.com/gorhill/uBlock/issues/284

Clicking on the empty space of a row will toggle
the visibility of the subdomains.

Additionally, the root context will always be visible
regardless of the expand/collspase state, along with
a visual indicator that a specific domain or subdomain
is the actual root context.  (the root context is the
hostname in which local rules are created).
2019-12-30 09:54:11 -05:00
Raymond Hill
2da8948928
Add basic syntax coloring to advanced settings pane 2019-12-24 10:04:18 -05:00
Raymond Hill
1bb524d12b
Still try to load filter lists after fatal error at launch
Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/issues/817#issuecomment-565730122

In case of a fatal error at launch, the loading of filter lists
could be skipped. With this commit uBO will still try to load
the filter lists, at least the default ones if no valid selfie
is present.
2019-12-14 11:14:00 -05:00
Raymond Hill
d90c8486aa
Fix reporting of csp-blocked resources in logger
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/552#issuecomment-561888900

Regression from:
- https://github.com/gorhill/uBlock/commit/7971b223855d
2019-12-04 19:23:57 -05:00
Raymond Hill
34504a0a1a
Fix regex-like filter representation in logger
Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/issues/805#issuecomment-561500819

uBO was testing for regex-like plain patterns after
prepending `@@` in the case of exception filters, thus
preventing proper detection of regex-like plain
patterns. The filtering engine was not affected, only
the proper rendering of the filter in the logger was
affected.
2019-12-04 10:42:03 -05:00
Raymond Hill
082201d24a
Fix reverse lookup of entity-based cosmetic filters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/805
2019-12-04 10:10:07 -05:00
Raymond Hill
91e702cebb
Enable CNAME uncloaking by default
Advanced setting `cnameAliasList` has been removed.

New advanced settings:

cnameUncloak:
  Boolean
Default value:
  true
Description:
  Whether to CNAME-uncloak hostnames.

cnameIgnoreExceptions:
  Boolean
Default value:
  true
Description:
  Whether to bypass the uncloaking of network requests
  which were excepted by filters/rules. This is
  necessary so as to avoid undue breakage by having
  exception filters being rendered useless as a result
  of CNAME-uncloaking.
  For example, `google-analytics.com` uncloaks to
  `www-google-analytics.l.google.com` and both hostnames
  appear in Peter Lowe's list, which means exception
  filters for `google-analytics.com` (to fix site
  breakage) would be rendered useless as the uncloaking
  would cause the network request to be ultimately
  blocked.
2019-12-01 12:05:49 -05:00
Raymond Hill
e98a4b1ace
Discard :: from parsed hosts files
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/800
2019-12-01 09:15:25 -05:00
Raymond Hill
0356e91ccb
Remove no longer used property 2019-12-01 09:01:20 -05:00
Raymond Hill
a16e4161de
Fine tune hostname uncloaking through CNAME-lookup
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/780

Related commit:
- https://github.com/gorhill/uBlock/commit/3a564c199260

This adds two new advanced settings:

- cnameIgnoreRootDocument
  - Default to `true`
  - Tells uBO to skip CNAME-lookup for root document.

- cnameReplayFullURL
  - Default to `false`
  - Tells uBO whether to replay the whole URL or just
    the origin part of it.
    Replaying only the origin part is meant to lower
    undue breakage and improve performance by avoiding
    repeating the pattern-matching of the whole URL --
    which pattern-matching was most likely already
    accomplished with the original request.

This commit is meant to explore enabling CNAME-lookup
by default for the next stable release while:

- Eliminating a development burden by removing the
  need to create a new filtering syntax to deal with
  undesirable CNAME-cloaked hostnames

- Eliminating a filter list maintainer burden by
  removing the need to find/deal with all base
  domains which engage in undesirable CNAME-cloaked
  hostnames

The hope is that the approach implemented in this
commit should require at most a few unbreak rules
with no further need for special filtering syntax
or filter list maintance efforts.
2019-11-23 13:07:23 -05:00
Raymond Hill
1b068c15fb
Fix token array being too small for very long URL
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/dzw57l/

Each token requires two slots in the token indices
array. This commit fixes uBO breaking when dealing
with very long URLs with lot of distinct tokens in
them.
2019-11-22 23:51:39 -05:00
Raymond Hill
68e1b58bb6
Trim trailing spaces from string values in advanced settings 2019-11-20 11:45:10 -05:00
Raymond Hill
563aed0d93
Code review for dns lookup code
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/780

- Handle DNS lookup failure

- Skip DNS lookup for non network-based URLs

- Benchmark code to be able to provide an estimate
  based on objective measurements regarding added
  overhead when DNS lookup is enabled
  (quick answer: a complete non-issue)
2019-11-20 10:45:17 -05:00
Raymond Hill
3a564c1992
Add ability to uncloak CNAME records
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/780

New webext permission added: `dns`, which purpose is
to allow an extension to fetch the DNS record of
specific hostnames, reference documentation:

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/dns

The webext API `dns` is available in Firefox 60+ only.

The new API will enable uBO to "uncloak" the actual
hostname used in network requests. The ability is
currently disabled by default for now -- this is only
a first commit related to the above issue to allow
advanced users to immediately use the new ability.

Four advanced settings have been created to control the
uncloaking of actual hostnames:

cnameAliasList: a space-separated list of hostnames.
Default value: unset => empty list.
Special value: * => all hostnames.
A space-separated list of hostnames => this tells uBO
to "uncloak" the  hostnames in the list will.

cnameIgnoreList: a space-separated list of hostnames.
Default value: unset => empty list.
Special value: * => all hostnames.
A space-separated list of hostnames => this tells uBO
to NOT re-run the network request through uBO's
filtering engine with the CNAME hostname. This is
useful to exclude commonly used actual hostnames
from being re-run through uBO's filtering engine, so
as to avoid pointless overhead.

cnameIgnore1stParty: boolean.
Default value: true.
Whether uBO should ignore to re-run a network request
through the filtering engine when the CNAME hostname
is 1st-party to the alias hostname.

cnameMaxTTL: number of minutes.
Default value: 120.
This tells uBO to clear its CNAME cache after the
specified time. For efficiency purpose, uBO will
cache alias=>CNAME associations for reuse so as
to reduce calls to `browser.dns.resolve`. All the
associations will be cleared after the specified time
to ensure the map does not grow too large and too
ensure uBO uses up to date CNAME information.
2019-11-19 12:05:33 -05:00
Raymond Hill
eec31fca8b
Save magic compiled/selfie format values in cache storage
Related issue:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1588916

Due to browser behavior changes during development,
uBO can end up using obsolete cached compiled filter
lists or selfie.

Saving magic format values in the cache storage
itself ensure uBO will properly detect actually
obsolete compiled lists/selfie.
2019-11-14 08:22:28 -05:00
Raymond Hill
e2fdc1b94b
Support keyboard shortcut to open popup panel
Related discussion:
- https://www.reddit.com/r/uBlockOrigin/comments/dt47s0/
2019-11-09 09:53:31 -05:00
Raymond Hill
7bf5ac0ca2
Code review of commit 4b34d29384
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/778

Related commit:
- 4b34d29384

Mind that `report-uri` or `report-to` could be
used somewhere in a hostname.
2019-11-09 07:32:19 -05:00
Raymond Hill
4b34d29384
Fix regex used to detect forbidden CSP directives
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/778
2019-11-09 06:59:59 -05:00
Raymond Hill
067ef5843c
Ensure that typeof of href attribute is string
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/777
2019-11-08 09:30:59 -05:00
Raymond Hill
ffae19270f
Coallesce mousemove events
Related commit:
- d1995778ff

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/615
2019-11-06 07:01:13 -05:00
Raymond Hill
d1995778ff
Allow element picker dialog to be moved around
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/615

There is a grab area under the text area, to be used
to move the dialog around.
2019-11-05 12:03:48 -05:00
Raymond Hill
522249bcb5
Fix test against opener tab id in popup filtering code
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/774

Regression from:
- f204d24bf4
2019-11-04 13:34:44 -05:00
Raymond Hill
ec5191004c
Use encodeURIComponent instead of btoa
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/772
2019-11-04 13:12:40 -05:00
Raymond Hill
da253bf80c
Use type="search" for search input fields
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/768

So that the input fields can gain extra built-in
browser widgets useful in search fields.
2019-11-03 13:14:29 -05:00
Raymond Hill
085a8cdbcc
Fine tune cosmetic filtering badge-related code
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/756

As per feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/756#issuecomment-549128106
2019-11-03 09:38:36 -05:00
Raymond Hill
571db71318
Fine tune cosmetic filtering badge-related code
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/756

As per various feedbacks:

Added an advanced setting to keep the original behavior,
which can be potentially costly CPU-wise on some sites:

    popupCosmeticFilterBadgeSlow

Default to `false`. Set to `true` to restore original
method of surveying the number of elements hidden as
a result of applying cosmetic filtering.

As suggested by <https://github.com/gwarser>, skip
descendant of nodes which have been found to be a
match in order to potentially increase the number
of nodes which can be surveyed in the alloted time.
2019-11-02 19:03:07 -04:00
Raymond Hill
4afc0764d2
Fix logic mistake in last commit
Related commit:
- 6d935c8925

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/756
2019-11-02 11:45:18 -04:00
Raymond Hill
6d935c8925
Bail out when counting hidden elements is too expensive
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/756

When trying the number of hidden elements as a result of
cosmetic filtering for popup panel badge purpose, the
code will bail out if this takes too long, and in such
case the badge will be set to `?`, meaning the number
of hidden elements is undetermined.
2019-11-02 09:16:23 -04:00
Raymond Hill
8acc39581c
Fine tune script tags survey scriptlet
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/756

The code used to count expensive-to-survey particular
inline javascript occurrences will be executed if and
only if no other script tags have been found in the
DOM. This is acceptable since the badge count is to be
deemed approximate (as per documentation).
2019-11-01 14:28:15 -04:00
Raymond Hill
987c9c1a21
Fix on-demand no-cosmetic-filtering badge when generichide in use
Related feedback:
- c090d2fde4 (commitcomment-35767596)

Mind that there might not be selectors to match as a
result of `generichide` or `no-cosmetic-filtering`.
2019-11-01 14:01:30 -04:00
Raymond Hill
c090d2fde4
Count hidden elements on-demand only in popup panel
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/756

The badge value for the no-cosmetic-filtering
switch will be evaluated on-demand only, when
the user hover over the switch with the mouse
cursor.

For touch screen displays, a tap on the switch
will cause the badge to be rendered if not
already done, otherwise this will toggle the
switch as usual.
2019-11-01 12:32:34 -04:00
Raymond Hill
7c0294bd5f
Fix spurious leading/trailing wildcards with valid token
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/dpcvfx/

Regression from:
- 7971b22385

Leading/trailing wildcards are useless when a valid
token can be found, and in such case they need to
be removed so as to ensure the proper filter class
is used.
2019-10-31 13:46:06 -04:00
Raymond Hill
d21b9388f3
Fix broken csp= filters when logger is opened
Regression from:
- 7971b22385

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/761
2019-10-31 12:43:33 -04:00
Raymond Hill
11c56ab540
Minor fine-tuning of URL tokenizer 2019-10-31 11:15:00 -04:00
Raymond Hill
d8975ee580
Improve efficiency of per-site switches badge code
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/756

This is the code used to find out the count values
displayed as badge on the cosmetic filtering and
scripting per-site switches in the popup panel.

The issue is that document.querySelector*() -- used to
find out the number of hidden elements -- is unduly
expensive on large DOM.

The changes in this commit have focused on avoiding the
use of document.querySelector*() as much as possible.

Also, the results are cached for reuse unless DOM
mutations are detected.
2019-10-31 11:07:11 -04:00
Raymond Hill
a69b301d81
Fine-tune new bidi-trie code
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/761
2019-10-29 10:26:34 -04:00
Raymond Hill
5cc797fb47
Add WASM implementation for BidiTrieContainer.matches()
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/761
2019-10-28 13:57:35 -04:00
Raymond Hill
d7b2d31180
Harden compiled/selfie format change detection at launch
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/759

This commit adds code to rely less on the state of the
cache storage to decide whether filter lists should be
re-compiled or whether the selfie is currently valid
at launch time when a change in compiled/selfie format
is detected.
2019-10-27 11:49:05 -04:00
Raymond Hill
b79445320d
Force-unsuspend when starting webRequest listener
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/759

If for some reasons the launch code throws, uBO could
find itself in permanent suspend mode, thus preventing
web pages from loading in Firefox.

Though uBO should not have exceptions thrown during
it's initialization code, this commit will ensure
uBO complete its initialization process should it
ever happen for whatever reason.
2019-10-27 11:41:08 -04:00
Raymond Hill
40de7d6489
Fix WASM memory allocation in bidi-trie
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/764
2019-10-27 08:36:17 -04:00
Raymond Hill
c71624d1da
Fix access to detached buffer when using WASM in bidi-trie
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/764

WebAssembly.Memory.grow() preserves the buffer content when
we grow it, no need to manually copy it. Doing so was
causing an access to a no longer valid ArrayBuffer.
2019-10-26 17:37:47 -04:00
Raymond Hill
0373410635
Fix comments in WASM code 2019-10-26 15:34:40 -04:00
Raymond Hill
6c3296958c
Fix last commit due to bad last second change
Related feedback:
- b0cbc47d9a (commitcomment-35677572)

It seems I completely forgot to test the last
"trivial" change to the WASM code.
2019-10-26 15:25:47 -04:00
Raymond Hill
b0cbc47d9a
Add WASM versions for some bidi-trie methods
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/761

Changes related to above issue made it possible to
create WASM versions of methods used in the bidi-trie.
In this commit, WASM versions for startsWith(), indexOf()
and lastIndexOf() have been implemented.
2019-10-26 13:13:53 -04:00
Raymond Hill
dd2a9faa4c
Use request as its own context when none available
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/dn9zso/

When a network request is tabless and contextless, i.e.
`tabId === -1` and `frameId === -1`, use the URL of
the network request as the context.
2019-10-26 10:18:32 -04:00
Raymond Hill
30393fdcf1
Exclude data type (i.e. csp=) from bidi-trie
We need a `matchAll()` method on the bidi-trie before
we can store filters of type `data` in it.

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

Related commit:
- 7971b22385
2019-10-22 18:14:49 -04:00