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

2529 Commits

Author SHA1 Message Date
Raymond Hill
19bdbddbfc
Emphase GitHub account requirement 2021-11-13 11:48:36 -05:00
Raymond Hill
e1c386515a
Report specific filter issue through a template
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1541#issuecomment-966697347
2021-11-12 09:11:28 -05:00
Raymond Hill
dea7184f30
Do not decode query parameter name when used as token
Related feedback:
- https://github.com/DandelionSprout/adfilt/discussions/163#discussioncomment-1628496
2021-11-12 08:24:30 -05:00
Raymond Hill
d142066f95
Fix incorrect redaction of user filterset
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1541#issuecomment-966543580
2021-11-11 14:06:59 -05:00
Raymond Hill
eccf613edf
Add ability to report filter issue from popup panel
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1541

A "chat" icon has been added to the popup panel to make
it easy to report filter issue on specific sites.

Reporting filter issues require a GitHub account, since
uBO does not have a home server through which reports could
be sent.

The report icon is available only for when uBO is enabled
on a given site.

On mobile devices, the logger icon is replaced by the "chat"
icon since it is more likely to be useful on small display
devices. The logger can always be opened from the Support
pane in the dashboard.
2021-11-11 12:49:55 -05:00
Raymond Hill
9fbc50f14f
Harden detection of // in style declaration
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1811#issuecomment-966323765
2021-11-11 09:05:10 -05:00
Raymond Hill
5d22b51668
Forbid usage of inage-set as style property
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1811

Additionally, forbid style declaration with at least one
instance of `//` at any position.
2021-11-11 08:33:28 -05:00
Raymond Hill
c2c2cef4e6
Fix bad test breaking list subscription
Related issue/feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1797#issuecomment-965150304
2021-11-10 08:49:28 -05:00
Raymond Hill
4efa6be96b
Fix sticky imported list after removal
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1803
2021-11-08 12:49:03 -05:00
Raymond Hill
97232baee3
Forbid multiple and unexpected CSS style declarations
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1806#issuecomment-963278382
2021-11-08 11:17:47 -05:00
Raymond Hill
630d436342
Forbid usage of opening comment /* in query-selectable test
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1806
2021-11-08 09:13:58 -05:00
Raymond Hill
5daa6a7ff3
Get current language using extensions API (instead of navigator.language)
Related feedback:
- https://github.com/gorhill/uBlock/pull/3860
2021-11-06 12:49:27 -04:00
Raymond Hill
c97d12c1d6
Remove bad test
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1798
2021-11-04 15:54:24 -04:00
Raymond Hill
955fe944ca
Suggest network filter as best candidate by default
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/qmjk36/

Regression from:
- d930504e3e

Also, fix immediately selecting the resource when using
contextual menu with cosmetic filtering off.
2021-11-04 12:42:48 -04:00
Raymond Hill
b63415a3db
Fix breaking navigation through links [regression]
Regression from:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1797
2021-11-04 11:48:07 -04:00
Raymond Hill
8b8b7da8d9
Forbid subscribing to filter lists with invalid URLs
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1797
2021-11-04 08:52:06 -04:00
Raymond Hill
2ab39aee23
Fix not highlighting cases of invalid syntax
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1791

The following case of invalid syntax was not reported as
invalid by the syntax highlighter:

    ... example.com image ...

With dynamic filtering, there can't be a specific
hostname when a specific type is used, or a
specific type when a specific hostname is used, one
or the other must be `*`.
2021-10-31 13:18:31 -04:00
Raymond Hill
8f2e1b4d84
Avoid testing sheet-selectability when filter is hinted as procedural
uBO support's `#?#`, which in AdGuard and ABP means that a
cosmetic filter is procedural.

However, uBO interprets this syntax as "probably procedural"
and will use the filter in a declarative way if the filter
is found to be stylesheet-compatible.

In reality though, the likelihood that a "probably procedural"
filter is sheet-selectable is very low, so treating the filter
as procedural a priori help saves pointless tests against
sheet-selectability when using lists primarily designed for
AdGuard or ABP.
2021-10-29 08:33:55 -04:00
Raymond Hill
3891b4d050
query-selectable selectors are not necessarily sheet-selectable
Related commits:
- 4f923384de
- 97a33c9572
- ef07171f5a

For instance, with "Experimental Web Platform features" enabled, the
following filter becomes natively query-selectable:

    .fail:has(+ a > b)

Meaning uBO won't need to emulate the `:has()` operator, it will
be executed natively using `querySelectorAll()`.

This commit fixes the erroneous assumption that a query-selectable
is also sheet-selectable.
2021-10-28 10:36:26 -04:00
Raymond Hill
ef07171f5a
Refactor how cosmetic filters with pseudo-elements are parsed
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1247#issuecomment-953284365

Distinguish between selectors which can be querySelector-ed
and/or used ni a stylesheet.
2021-10-27 18:09:02 -04:00
Raymond Hill
97a33c9572
Fix test for stylesheet presence
Related commit:
- 4f923384de
2021-10-27 15:13:13 -04:00
Raymond Hill
4f923384de
Use an actual stylesheet to validate cosmetic filters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1751

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

It turns out Chromium has started to implement the `:has()`
operator, which becomes recognized when the browser flag
"Experimental Web Platform features" is enabled. However the
hic is that `:has()` is not supported as a declarative CSS
style rule and is only supported through `querySelector()`
et al.

The fix is to no longer detect plain CSS selectors through
`querySelector` et al. but rather use an actual stylesheet
to validate that a cosmetic filter can be injected into a
stylesheet in a declarative way.

Additionally, I added support to enforce ABP's semantic
regarding cosmetic filter with the `#?#` anchor: when using
such anchor, uBO will _first_ try to compile the filter as
a procedural one rather than a declarative one.

Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1011#issuecomment-884824166
2021-10-27 12:56:37 -04:00
Raymond Hill
5bea149e8f
Fix spurious errors in uBO's dev console
Those spurious errors occurred when launching the browser
with the dashboard already opened from the previous
browsing session.
2021-10-26 08:54:04 -04:00
Raymond Hill
c136c7b454
Auto-escape commas in removeparam's regexes
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/760#issuecomment-951146371

This is a quick fix, some refactoring necessary for a more
comprehensive fix to all such issues.
2021-10-26 08:51:55 -04:00
Raymond Hill
d5cfd673dc
Condense list details in Support pane
Related commit:
- a3a43c7cb4
2021-10-22 14:59:41 -04:00
Raymond Hill
65985343fc
Create new page store if not found in tab event
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/757

Sometimes a tab event may fire for a tab which is not
yet known to uBO. In such case, bind the tab internally
so that it can be processed properly in the future.
2021-10-18 09:43:41 -04:00
Raymond Hill
c44117aa70
Further fine tune Support pane
Related commit:
- a3a43c7cb4
2021-10-16 08:43:31 -04:00
Raymond Hill
cd5f58779b
Also check for unsupported tags in descendants 2021-10-16 08:42:55 -04:00
Raymond Hill
c7f1af9547
Fix regression in DOM inspector
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1765

Related commit:
- 1285f78e05 (diff-77e1325098616e4d2bb6b1e9ccf3b7cb9898942739e29f01b63346220f55b2b8L250-R250)
2021-10-15 16:55:40 -04:00
Raymond Hill
730735cc5e
Further fine-tune new Support pane
Related commit:
- a3a43c7cb4

Specifically:
- Support i18n
- Autofill issues opened through Support pane with configuration
  information
- Remove from About pane items found in Support pane
2021-10-15 14:50:34 -04:00
Raymond Hill
2c7fcf7284
Simplify handling of valid HTML tags in i18n files
Use DOMParser instead of trying to manually parse
the HTML tags appearing in i18n files.
2021-10-15 14:49:02 -04:00
Raymond Hill
24553163c5
Minor fixes to new Support page 2021-10-14 12:00:24 -04:00
Raymond Hill
aceaea0122
Minor code review 2021-10-14 09:22:36 -04:00
Eli Grey
1285f78e05
Don't assume document.documentElement is non-null (#3857)
* Fix uBlockOrigin/uBlock-issues#1756

This PR fixes uBlockOrigin/uBlock-issues#1756.

* fix dom-inspector.js

* more explicit if statements

* these changes should also be safe
2021-10-14 09:08:08 -04:00
Raymond Hill
9d0e72b243
Further fine-tuning new Support pane
Related commit:
- a3a43c7cb4
2021-10-14 08:54:38 -04:00
Raymond Hill
f9989f30d8
Further improve new Support pane
For now the language locales are not available as the text on
the page needs to stabilize before asking translation
volunteers to contribute their time working on the new text.
2021-10-13 11:18:23 -04:00
Raymond Hill
e7444883a3
Fine tune data reported in Support pane
Related commit:
- a3a43c7cb4
2021-10-13 08:31:04 -04:00
Raymond Hill
6836809aad
Make Shortcut pane not present by default [Firefox]
By default uBO assumed the Shortcut pane was needed,
unless it found the current version of FF was higher
than 73. This commit reverses the test, it assumes
the Shortcut pane is not needed, unless the current
version is lower than 74.
2021-10-13 08:23:20 -04:00
Raymond Hill
a3a43c7cb4
Add "Support" pane to dashboard
The purpose is to allow users to make it easy to share
technical information about their uBO configuration, and
to make it easy for volunteers to diagnose issues.

This is a first step toward the goal of making it easier
for users to report issues with either uBO or filter
issues on websites.

Related issues:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1701
- https://github.com/uBlockOrigin/uBlock-issues/issues/1541
2021-10-12 11:19:56 -04:00
Raymond Hill
01cbe7520d
Fix regression with no-cosmetic-filtering switch
Related commit:
- c4b7ee80ea
2021-10-11 07:07:41 -04:00
Raymond Hill
c4b7ee80ea
Further work on JS modules
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1664
2021-10-07 14:41:29 -04:00
Raymond Hill
c0cba22771
Fix regression of isBlockImportant()
isBlockImportant() was relying strictly on the hash bits
to detect whether a matching filter was `important`, but
this approach regressed with changes with how `important`
filters are compiled. This commit fixed this by no longer
relying on the hash bits but rather on an internal
register variable being set by `important` filters when
they match.

I couldn't find any actual cases in default filter lists
(including a couple of default regional lists) that the
regression is having any effect, due to the limited cases
for which isBlockImportant() is called.

A test was added in a previous commit to detect such
regression in the future:
- a76935b232
2021-10-06 09:57:49 -04:00
Raymond Hill
6464002088
Give precedence to negated types in case of ambiguity
Related feedback:
- https://github.com/uBlockOrigin/uAssets/issues/7639#issuecomment-933525018
2021-10-06 09:44:15 -04:00
Raymond Hill
a6cd954a2a
Fix handling of negated types in all filter option
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1730

Related commit:
- 8f98622374
2021-09-25 12:36:33 -04:00
Raymond Hill
1130746a9b
Fix regression with important filter option
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1732

The regression affect filter with the `important` option when
the following conditions were fulfilled:

- The filter pattern is pure hostname
- The filter has not one of the following options:
  - domain
  - denyallow
  - header
  - strict1p, strict3p
  - csp
  - removeparam
- There is a matching exception filter

Related commit:
- a2a8ef7e85

A related mocha test has been added in order to detect this
specific regression in the future through `make test`.
2021-09-24 11:09:32 -04:00
Raymond Hill
8f98622374
Refactor implementation of ~[type] filter options
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1730

A new filter unit, FilterNotType, is introduced to enforce
negated filter type options.

Before this commit, there was no actual negated types in the
static network filtering engine, as a negated type was internally
converted to non-negated types at compile time. As a result,
the logger would never output a matching filter with its original
negated type options.

This commit no longer causes an internal conversion to take place
at compile time, but explicitly enforce negated types at match time,
and as a result the logger will from now on output matching filter
with their original negated type options.
2021-09-23 09:38:27 -04:00
Raymond Hill
f49c4e254b
Add advanced setting to default modify webext flavor
Name: modifyWebextFlavor

Value: A list of space-separated tokens to be added/removed from the
computed default webext flavor.

The primary purpose is to give filter list authors the ability to
test mobile flavor on desktop computers. Though mobile versions of
web pages can be emulated using browser dev tools, it's not
possible to do so for uBO itself.

By using `+mobile` as a value for this setting will force uBO
to act as if it's being executed on a mobile device.

Important: this setting is best used in a dedicated browser
profile, as this affects how filter lists are compiled. So best
to set it in a new browser profile, then force all filter lists
to be recompiled, and use the profile in the future when there
is a need to test the specific webext flavor.
2021-09-22 09:37:21 -04:00
Raymond Hill
33a18c3a1e
Convert fingerprint2.js scriptlet into a redirectable resource
As per internal discussion with volunteer filter list
maintainers.
2021-09-18 10:55:22 -04:00
Raymond Hill
4100761863
Keep ability to prevent local IP address leaks for mobile version
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1723

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1723#issuecomment-919913361
2021-09-15 08:28:10 -04:00
Raymond Hill
831cf478da
Revert "Remove now obsolete webrtc-related setting"
This reverts commit af41aadab7.
2021-09-15 07:40:32 -04:00
Raymond Hill
af41aadab7
Remove now obsolete webrtc-related setting
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1723

The leaking of local IP addresses is no longer an issue
in modern browsers.
2021-09-14 10:04:35 -04:00
Raymond Hill
d930504e3e
Better lookup all elements under mouse cursor in element picker
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/pefaov/elementpickerzapper_often_misses_images/hcnycbx/?context=3
2021-09-13 10:39:17 -04:00
Raymond Hill
a3a66d0e31
Avoid parsing query parameters with URLSearchParams
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1717
2021-09-12 12:17:46 -04:00
Eli Grey
6e6697fab6
Fix typo in comment about buffer expiry
The code below the comment specifies 30 seconds, while the comment says 60 seconds. This PR fixes that typo to make the comment indicate 30 seconds.
2021-08-26 17:03:39 -07:00
Raymond Hill
46eb3801ec
Revert "Inject scriptlets at webNavigation.onCommitted time in Firefox"
This reverts commit 7ee9c21b37.

Potentially related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1696
2021-08-26 18:36:36 -04:00
Raymond Hill
7ee9c21b37
Inject scriptlets at webNavigation.onCommitted time in Firefox
Just as is the case with Chromium.

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1694
2021-08-25 09:24:10 -04:00
Raymond Hill
a2d8545382
Forbid instances of /* in :style() operator
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1693
2021-08-25 07:43:26 -04:00
Raymond Hill
6dcd5df991
Take into account simple selectors present in array of selectors
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1692
2021-08-24 12:29:48 -04:00
Raymond Hill
f0b46bde4f
Mitigate generic cosmetic filters erroneously targeting html/body
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1692

The ids/classes from html/body elements will leave out
looking up lowly generic cosmetic filters made of a single
identifier.

This does not absolutely guarantee that html/body elements
will never be targeted, but it should greatly mitigate the
probability that this erroneously happens.
2021-08-24 10:03:25 -04:00
Manish Jethani
925c01dc14
Fix ESLint globals error in biditrie.js (#3850) 2021-08-23 11:10:49 -04:00
Manish Jethani
d959c7aabe
Remove globals.js (#3849) 2021-08-23 10:54:16 -04:00
Manish Jethani
d13294dd39
Remove globals usage from background.js (#3848) 2021-08-23 10:28:44 -04:00
Manish Jethani
724a946c79
Remove globals usage from start.js (#3847) 2021-08-23 10:16:02 -04:00
Manish Jethani
9761b02c79
Convert publicsuffixlist.js into an ES module (#3846) 2021-08-23 09:42:27 -04:00
Raymond Hill
ba83c21354
Fix trie instance iterator 2021-08-22 13:06:05 -04:00
Manish Jethani
9ddbb293c0
Convert punycode.js into an ES module (#3845) 2021-08-22 12:03:59 -04:00
Manish Jethani
1bde1e5ecb
Convert regex.js into an ES module (#3844) 2021-08-22 08:25:06 -04:00
Raymond Hill
9d4006f2c3
Include query string when evaluating matches-path()
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1690#issuecomment-903133439
2021-08-21 11:50:46 -04:00
Raymond Hill
c0c70e2987
Fix normalization of matches-path operator
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1690
2021-08-21 10:20:43 -04:00
Raymond Hill
9dece3bd30
Add new procedural cosmetic operator: :matches-path(...)
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1690

New procedural operator: `:matches-path(...)`

Description: this is a all-or-nothing passthrough operator, which
on/off behavior is dictated by whether the argument match the
path of the current location. The argument can be either plain
text to be found at any position in the path, or a literal regex
against which the path is tested.

Whereas cosmetic filters can be made specific to whole domain,
the new `:matches-path()` operator allows to further narrow
the specificity according to the path of the current document
lcoation.

Typically this procedural operator is used as first operator in
a procedural cosmetic filter, so as to ensure that no further
matching work is performed should there be no match against the
current path of the current document location.

Example of usage:

    example.com##:matches-path(/shop) p

Will hide all `p` elements when visiting `https://example.com/shop/stuff`,
but not when visiting `https://example.com/` or any other page
on `example.com` which has no instance of `/shop` in the path part
of the URL.
2021-08-21 09:41:48 -04:00
Manish Jethani
5d2c295600
Remove globals usage from hntrie.js (#3842) 2021-08-21 07:33:53 -04:00
Manish Jethani
ab13903019
Remove globals usage from static-net-filtering.js (#3841) 2021-08-20 07:54:05 -04:00
Raymond Hill
19160f9018
Drop requestIdleCallback from globals
Related discussion:
- https://github.com/gorhill/uBlock/pull/3839

`requestIdleCallback` can be assumed always present on
browser-related platforms.
2021-08-19 07:31:27 -04:00
Raymond Hill
68675ed1cd
Remove pointless dependency on location
Related discussion:
- https://github.com/gorhill/uBlock/pull/3839#discussion_r691502793
2021-08-19 07:23:53 -04:00
Manish Jethani
b19393d8dc
Add tasks.js module (#3839) 2021-08-19 07:19:20 -04:00
Raymond Hill
9ceef65f9a
Fix regression with reporting "important" in logger
Related feedback:
- a2a8ef7e85 (commitcomment-54972030)
2021-08-17 07:32:54 -04:00
Raymond Hill
a33f70cf20
Provide compiler/selfie versions for snfe
So as to allow nodejs usage to better deal with
out of date serialization/compilation.

Additionally, use FilterImportant() only when a
"block-important" filter is stored in the "block" realm.
2021-08-16 12:15:30 -04:00
Raymond Hill
a2a8ef7e85
Avoid matching the block-important realm unconditionally
When matching a network request in the static network filtering
engine ("snfe"), these are the possible outcomes, from most
to least likely:

- No block
- Block
- Unblock ("exception" filter overriding the block)
- Block-important ("important" filter override the unblock)

Hence why the matching in the snfe always check for a match in
the "block" realm, and the "unblock" realm would be checked
if and only if there was a match in the "block" realm.

However the "block-important" realm was always matched against
first, and when a match in that realm was found, there would
be no need to check in other realms since nothing can override
the "important" option. The problem with this approach though
is that matches in the "block-important" realm are most
unlikely, which means pointless work being done for vast
majority of network requests.

This commit makes it so that the "block-important" realm is
matched against ONLY when there is a matched "unblock" filter.
The result is a measurable improvement in the snfe-related
benchmarks (though given the numbers involved, end users won't
perceive a difference).

Somewhat related discussion which was the motivation to look
more into this:

https://github.com/cliqz-oss/adblocker/discussions/2170#discussioncomment-1168125
2021-08-16 10:58:04 -04:00
Raymond Hill
c6fb70b1f0
Refactor hntrie to avoid the need for boundary cells
Whereas before the string segment was encoded as:

LL OOOOOOOOOOOO

where L are the upper 8 bits and used to encode the length
of the segment, and O are the lower 24 bits and used to
encode the offset of the string data in the character
buffer, the new code encode as follow:

OOOOOOOOOOOO LL

And furthermore the most significant bit of the length
LL is now used to mark whether the current string segment
is a label boundary.

This means a cell can't reference a segment longer then
127 characters. To work around this limitation for when a
segment is longer than 127 characters (a rare occurrence),
the algorithm will simply split the segment into multiple
adjacent cells.

As a result, there is no longer a need to encode
"boundariness" into special cells, which simplifies
both the storing and matching algorithms.

Additionally, added minimal documentation for the NPM
package on how to import and use HNTrieContainer as a
standalone API.
2021-08-10 09:27:59 -04:00
Raymond Hill
b54bf554a8
Fix bad test in WASM version of HNTrieContainer
The erroneous test does not seem to interfere
with the proper functioning of the trie, due
to the fact that nodes are never split without
a OR node or boundary node being present.

The issue was found when undertaking a rewrite
of the algorithm to avoid having to create
boundary nodes.
2021-08-09 07:02:00 -04:00
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