2021-07-31 12:49:32 -06:00
|
|
|
#!/usr/bin/env bash
|
2021-07-25 08:55:35 -06:00
|
|
|
#
|
|
|
|
# This script assumes a linux environment
|
|
|
|
|
2021-07-31 15:34:25 -06:00
|
|
|
set -e
|
|
|
|
|
2021-08-15 08:43:36 -06:00
|
|
|
DES=$1
|
2021-08-03 05:02:48 -06:00
|
|
|
|
2021-07-25 08:55:35 -06:00
|
|
|
mkdir -p $DES/js
|
|
|
|
cp src/js/base64-custom.js $DES/js
|
|
|
|
cp src/js/biditrie.js $DES/js
|
2021-08-03 10:19:25 -06:00
|
|
|
cp src/js/dynamic-net-filtering.js $DES/js
|
2021-07-25 08:55:35 -06:00
|
|
|
cp src/js/filtering-context.js $DES/js
|
2021-08-03 10:19:25 -06:00
|
|
|
cp src/js/hnswitches.js $DES/js
|
2021-07-25 08:55:35 -06:00
|
|
|
cp src/js/hntrie.js $DES/js
|
2022-10-16 10:05:24 -06:00
|
|
|
cp src/js/redirect-resources.js $DES/js
|
2022-09-06 11:47:52 -06:00
|
|
|
cp src/js/static-dnr-filtering.js $DES/js
|
2021-07-25 08:55:35 -06:00
|
|
|
cp src/js/static-filtering-parser.js $DES/js
|
|
|
|
cp src/js/static-net-filtering.js $DES/js
|
|
|
|
cp src/js/static-filtering-io.js $DES/js
|
2021-08-19 05:19:20 -06:00
|
|
|
cp src/js/tasks.js $DES/js
|
2021-07-31 06:59:55 -06:00
|
|
|
cp src/js/text-utils.js $DES/js
|
2021-07-25 08:55:35 -06:00
|
|
|
cp src/js/uri-utils.js $DES/js
|
2021-08-03 10:19:25 -06:00
|
|
|
cp src/js/url-net-filtering.js $DES/js
|
2021-07-25 08:55:35 -06:00
|
|
|
|
|
|
|
mkdir -p $DES/lib
|
New cosmetic filter parser using CSSTree library
The new parser no longer uses the browser DOM to validate
that a cosmetic filter is valid or not, this is now done
through a JS library, CSSTree.
This means filter list authors will have to be more careful
to ensure that a cosmetic filter is really valid, as there is
no more guarantee that a cosmetic filter which works for a
given browser/version will still work properly on another
browser, or different version of the same browser.
This change has become necessary because of many reasons,
one of them being the flakiness of the previous parser as
exposed by many issues lately:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2262
- https://github.com/uBlockOrigin/uBlock-issues/issues/2228
The new parser introduces breaking changes, there was no way
to do otherwise. Some current procedural cosmetic filters will
be shown as invalid with this change. This occurs because the
CSSTree library gets confused with some syntax which was
previously allowed by the previous parser because it was more
permissive.
Mainly the issue is with the arguments passed to some procedural
cosmetic filters, and these issues can be solved as follow:
Use quotes around the argument. You can use either single or
double-quotes, whichever is most convenient. If your argument
contains a single quote, use double-quotes, and vice versa.
Additionally, try to escape a quote inside an argument using
backslash. THis may work, but if not, use quotes around the
argument.
When the parser encounter quotes around an argument, it will
discard them before trying to process the argument, same with
escaped quotes inside the argument. Examples:
Breakage:
...##^script:has-text(toscr')
Fix:
...##^script:has-text(toscr\')
Breakage:
...##:xpath(//*[contains(text(),"VPN")]):upward(2)
Fix:
...##:xpath('//*[contains(text(),"VPN")]'):upward(2)
There are not many filters which break in the default set of
filter lists, so this should be workable for default lists.
Unfortunately those fixes will break the filter for previous
versions of uBO since these to not deal with quoted argument.
In such case, it may be necessary to keep the previous filter,
which will be discarded as broken on newer version of uBO.
THis was a necessary change as the old parser was becoming
more and more flaky after being constantly patched for new
cases arising, The new parser should be far more robust and
stay robist through expanding procedural cosmetic filter
syntax.
Additionally, in the MV3 version, filters are pre-compiled
using a Nodejs script, i.e. outside the browser, so validating
cosmetic filters using a live DOM no longer made sense.
This new parser will have to be tested throughly before stable
release.
2022-09-23 14:03:13 -06:00
|
|
|
cp -R src/lib/csstree $DES/lib/
|
2021-07-25 08:55:35 -06:00
|
|
|
cp -R src/lib/punycode.js $DES/lib/
|
|
|
|
cp -R src/lib/regexanalyzer $DES/lib/
|
2021-07-31 05:06:11 -06:00
|
|
|
cp -R src/lib/publicsuffixlist $DES/lib/
|
|
|
|
|
|
|
|
# Convert wasm modules into json arrays
|
|
|
|
mkdir -p $DES/js/wasm
|
2022-09-06 11:47:52 -06:00
|
|
|
cp src/js/wasm/* $DES/js/wasm/
|
2021-07-31 05:06:11 -06:00
|
|
|
node -pe "JSON.stringify(Array.from(fs.readFileSync('src/js/wasm/hntrie.wasm')))" \
|
|
|
|
> $DES/js/wasm/hntrie.wasm.json
|
|
|
|
node -pe "JSON.stringify(Array.from(fs.readFileSync('src/js/wasm/biditrie.wasm')))" \
|
|
|
|
> $DES/js/wasm/biditrie.wasm.json
|
|
|
|
node -pe "JSON.stringify(Array.from(fs.readFileSync('src/lib/publicsuffixlist/wasm/publicsuffixlist.wasm')))" \
|
|
|
|
> $DES/lib/publicsuffixlist/wasm/publicsuffixlist.wasm.json
|
2021-07-25 08:55:35 -06:00
|
|
|
|
2021-08-05 12:36:13 -06:00
|
|
|
cp platform/nodejs/*.js $DES/
|
|
|
|
cp platform/nodejs/README.md $DES/
|
|
|
|
cp LICENSE.txt $DES/
|