1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-15 15:32:28 +02:00
Commit Graph

82 Commits

Author SHA1 Message Date
Viktor Szépe
c23a9ada33
Fix typos 2023-07-23 10:01:08 -04:00
Raymond Hill
33c437f99f
Add source code viewer (from logger)
This commits add the ability to open html/css/script
resources from the logger, as a formatted and syntax-
highligthed document.

The goal is to make it easier for filter list authors to
investigate filter-related issues.
2023-03-01 11:04:40 -05:00
Raymond Hill
45139d8fdc
Import version 1.2.0 of RegexAnalyzer
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2374
2023-01-01 10:15:24 -05:00
Raymond Hill
d80ac4f292
Import version 1.2.0 of https://github.com/foo123/RegexAnalyzer
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2374
2023-01-01 10:00:33 -05:00
Raymond Hill
c818065c69
Update fix to regex library
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2374
2022-11-19 09:54:34 -05:00
Raymond Hill
69b899d0f9
Fix commit reference 2022-11-17 10:27:40 -05:00
Raymond Hill
d9744d012a
Document changes to imported library 2022-11-17 08:53:41 -05:00
Raymond Hill
d51b7e082b
Improve extraction of tokens from regexes
Fixed flawed extraction of tokens with optional sequences, i.e.
when quantifier could be zero.
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2367

Ignore look-around sequences as suggested when normalizing into
tokenizable string.
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2368

Fix regex analyzer throwing with trailing `-` in character
class sequence.
Related issue:
- https://github.com/AdguardTeam/AdguardFilters/pull/134630
2022-11-17 08:53:41 -05:00
Raymond Hill
a71b71e4c8
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 16:03:13 -04:00
Dominik 'Rathann' Mierzejewski
798338e7fa use WebAssembly-1.0 compliant function names
These functions were renamed in 2018, before the WebAssembly 1.0 spec
was finalized. wabt 1.0.25 dropped support for pre-1.0 names and the
sources fail to compile with errors like:

```
$ wat2wasm lz4-block-codec.wat
lz4-block-codec.wat:71:5: error: unexpected token get_local, expected ).
    get_local $ilen
    ^^^^^^^^^
lz4-block-codec.wat:78:5: error: unexpected token get_local.
    get_local $ilen
    ^^^^^^^^^
```
2022-05-22 17:34:12 +02:00
myersg86
6573a59a59
Fix typos in README, docs, and JS comments 2022-03-13 08:56:26 -04:00
Raymond Hill
c78178055a
Fix comment 2022-02-23 08:40:07 -05:00
Raymond Hill
5619840066
Fix previous commit regarding PSL
The library itself was fixed properly but failed to
properly transcribe the fix manually.

Related commit:
- 38855b1ff6
2022-02-22 19:16:16 -05:00
Raymond Hill
38855b1ff6
Fix testing a 8-bit integer instead of a 32-bit integer in PSL library
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2002

The code was testing only the LSB of a 32-bit integer to detect
whether the current rule was a wildcard (`*`), while it had to
compare against the whole 32-bit integer.

The breakage occurred when the LSB of an offset to the character
buffer happened to match the ASCII code of `*` (42, 0x2A).

(An offset is used when a label is longer than 4 characters)
2022-02-22 18:53:50 -05:00
Raymond Hill
ad7eb5d1da
Provide exact link for the origin of the library
As per AMO review team request.

Related documentation:
- https://extensionworkshop.com/documentation/publish/third-party-library-usage/
2022-02-09 13:11:38 -05:00
Raymond Hill
3b0b240b9b
Add information about exact origin of the library as per AMO review request 2022-02-09 12:57:37 -05:00
Raymond Hill
ecb73d2ff5
Bring dark theme out of experimental status
Too many changes to list here, essentially there is now a
user interface setting to enable/disable dark theme, and
I've rearranged a bit the Settings pane as a result and
also altered other visuals in various places.

There are places which I know have not been thoroughly
tested (i.e. logger inspector).

Will fine-tune as per feedback.

Issues with the classic popup panel will not be addressed,
and if feedback is that it has become unusuable, it will be
outright removed.
2022-02-02 15:40:47 -05:00
Raymond Hill
9d0e72b243
Further fine-tuning new Support pane
Related commit:
- a3a43c7cb4
2021-10-14 08:54:38 -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
Manish Jethani
19fb513d52
Update ./wasm/* files from publicsuffixlist.js (#3853) 2021-08-28 10:32:29 -04:00
Manish Jethani
498f90966d
Bring suffixInPSL() from upstream (#3851) 2021-08-26 08:50:49 -04:00
Manish Jethani
9761b02c79
Convert publicsuffixlist.js into an ES module (#3846) 2021-08-23 09:42:27 -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
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
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
e85c6f2d3e
Merge background changes to user filters in "My filters" pane
Related issue:
- https://github.com/gorhill/uBlock/issues/3704
2021-07-17 12:03:56 -04:00
Raymond Hill
0dfafc3bd3
Upgrade CodeMirror to 5.59.2
This should fix the following issue:
- https://www.reddit.com/r/uBlockOrigin/comments/lnfyer/

CodeMirror was detecting Windows as iOS:
- https://github.com/codemirror/CodeMirror/issues/6532
2021-02-19 13:07:34 -05:00
Raymond Hill
426395aa03
Improve extraction of tokens from regex-based filters
Regex-based static network filters are those most likely to
cause performance degradation, and as such the best guard
against undue performance degradation caused by regex-based
filters is the ability to extract valid and good tokens
from regex patterns.

This commit introduces a complete regex parser so that the
static network filtering engine can now safely extract
tokens regardless of the complexity of the regex pattern.

The regex parser is a library imported from:
https://github.com/foo123/RegexAnalyzer

The syntax highlighter adds an underline to regex-based
filters as a visual aid to filter authors so as to avoid
mistakenly creating regex-based filters. This commit
further colors the underline as a warning when a regex-based
filter is found to be untokenizable.

Filter list authors are invited to spot these untokenizable
regex-based filters in their lists to verify that no
mistake were made for those filters, causing them to be
untokenizabke. For example, what appears to be a mistake:

    /^https?:\/\/.*\/sw.js?.[a-zA-Z0-9%]{50,}/

Though the mistake is minor, the regex-based filter above
is untokenizable as a result, and become tokenizable when
the `.` is properly escaped:

    /^https?:\/\/.*\/sw\.js?.[a-zA-Z0-9%]{50,}/

Filter list authors can use this search expression in the
asset viewer to find instances of regex-based filters:

    /^(@@)?\/[^\n]+\/(\$|$)/
2020-12-26 08:52:42 -05:00
Raymond Hill
5d617484e5
Upgrade CodeMirror library to 5.59.0 (from 5.46.0) 2020-12-22 09:06:26 -05:00
Raymond Hill
23332400f5
Improve annotations for search operations in CodeMirror editor
Before this commit, CodeMirror's add-on for search occurrences
was limited to find at most 1000 first occurrences, because of
performance considerations.

This commit removes this low limit by having the search
occurrences done in a dedicated worker. The limit is now
time-based, and highly unlikely to ever be hit under normal
condition.

With this change, all search occurrences are gathered,
and as a result:

- All occurrences are reported in the scrollbar instead of
just the 1,000 first

- The total count of all occurrences is now reported, instead
of capping at "1000+".

- The current occurrence rank at the cursor or selection
position is now reported -- this was not possible to report
this before.

The number of occurrences is line-based, it's not useful to
report finer-grained occurences in uBO.
2020-08-02 12:18:01 -04:00
Raymond Hill
f55c891d54
Avoid returning a value when injected as content script 2020-07-20 17:28:33 -04:00
Raymond Hill
e44a568278
Add CoreMirror's code-folding ability to list editor/viewer
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1134

CodeMirror's code folding reference:
- https://codemirror.net/doc/manual.html#addon_foldcode

This commit adds support for code-folding to the filter
list editor/viewer.

The following blocks of code are foldable by clicking the
corresponding marker in the gutter:

- !#if/#endif blocks
- !#include blocks

Addtionally, the following changes:

- The `!#include` line is now preserved when importing a
  sublist
- The `!#if` directives will be syntax-colored according
  to whether they evaluate to true or false on the current
  platform
- Double-clicking on a foldable line in the gutter will
  select the content of the foldable block
- Minor visual improvement to matching brackets
2020-07-10 08:01:39 -04:00
Raymond Hill
3e72a47c1f
Add support for auto-completion in _My filters_ pane
This commit adds CodeMirror's auto-completion capability
to the _My filters_ pane.

Currently, auto-completion is available for scriptlet
tokens: pressing ctrl-space while the text cursor is
positioned where a scriptlet token should appear will
cause auto-completion to kick-in. In case of ambiguity,
CodeMirror's widget to pick a specific scriptlet will
appear.
2020-06-15 09:15:13 -04:00
Raymond Hill
0e32e4391d
Add ability to comment out block of filters
Pressing Tab in _My filters_ will toggle the
commenting out of filters in the current
selection or current line if no selection.
2020-06-14 14:02:33 -04:00
Raymond Hill
6d8b310d94
Minor code review of static filtering parser
Rename `l` property to `len`, to avoid ambiguity as
`l` could mean _left_ or _length_. Typically `l` is
to be used for _left_ (whereas `r` is to be used for
_right_).

Additionally, add CodeMirror's bracket-matching and
bracket auto-closing to _My filters_ pane and and
bracket-matching to asset viewer page.
2020-06-14 12:05:42 -04:00
Raymond Hill
f667fc2d65
Fix page count computation in publicSuffixList.enableWASM() 2019-04-25 19:40:07 -04:00
Raymond Hill
cd1a11fa9d
Update to CodeMirror version 5.46 2019-04-23 19:06:03 -04:00
Raymond Hill
f47ad8366e
Fix https://github.com/NanoAdblocker/NanoCore/issues/257 2019-04-03 00:18:16 -03:00
Raymond Hill
d505adfa38
Upgrade CodeMirror to 5.45 2019-03-31 00:31:29 -03:00
Raymond Hill
008370e4b9
Fix https://github.com/uBlockOrigin/uBlock-issues/issues/461
uBO will fallback using a JSON string when trying to encode an array
buffer in Chromium version 59 and earlier.
2019-03-16 09:00:31 -04:00
Raymond Hill
2fb4dc8358
Update PSL library to latest official version 2019-02-12 12:00:20 -05:00
Raymond Hill
1e2969c3b0
Update PSL library to last version 2019-02-12 07:59:38 -05:00
Raymond Hill
4da340384a
Update publicSuffixLibrary to latest (WASM-able) version
See https://github.com/gorhill/publicsuffixlist.js
2019-02-10 12:19:05 -05:00
Raymond Hill
69c87c5117
Fix Promise chain of WASM module load operations
The Promise chain was not properly designed for WASM module
loading. This became apparent when removing WASM modules
from Opera build[1].

The problem was that errors thrown by fetch() -- used to
load WASM modules -- were not properly handled.

[1] Opera refuses updating uBO if there are unrecognized file
types in the package, and `.wasm`/`.wat` files are not
recognized by Opera uploader.
2019-02-01 08:20:43 -05:00
Raymond Hill
2be36ffe81
Fix bad alignment in comments 2018-12-22 12:26:50 -05:00
Raymond Hill
0ce42fa23d
Apply fix to diff code as per http://www.mathertel.de/Diff/DiffTest.aspx?oldfile=Diff.cs.v1&newfile=Diff.cs.v2 2018-12-20 18:57:06 -05:00
Raymond Hill
9b27a98f90
Fix https://github.com/gorhill/uBlock/issues/3654
Additionally, there has been refactoring work done regarding
filtering context used throughout uBO, motivated by the fix
here.
2018-12-13 12:30:54 -05:00
Raymond Hill
5fd3f82205
Update README.md 2018-10-19 12:02:04 -03:00
Raymond Hill
3076b0f4fa
include source code of lz4-block-codec.wasm for reviewers 2018-10-19 11:56:28 -03:00