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

2041 Commits

Author SHA1 Message Date
Raymond Hill
2523959f20
Better handling of separator errors in domain lists
Specifically, do not invalidate valid hostnames when
there are extraneous separators: that sort of error
will be visually highlighted but will not otherwise
prevent a filter from being properly enforced.
2020-06-13 17:04:42 -04:00
Raymond Hill
a211c2c95d
Convert selector compiler closured code into standalone class
This ensures proper garbage collection once the parser
is no longer referenced -- this is important now that
the parser is instantiated on-demand only.
2020-06-13 12:53:49 -04:00
Raymond Hill
0ec4c911dd
Fix improper handling of regex flags in search widget
Reported internally.

Potential regex flags are passed as is to RegExp contructor,
and in case of failure the query is deemed a plain text one.

Related commit:
- 8de67d22bd (diff-3f4aa453cefa49f6431f1bba3bb53a8e)
2020-06-13 11:13:48 -04:00
Raymond Hill
1a082e0581
Expand parser's ability to process static extended filtering
This commit moves some of the parsing logic of static
extended filtering into the static filtering parser; this
allows better syntax highlighting and creation-time
error-catching for cosmetic, HTML, and scriptlet filters.
2020-06-13 08:48:56 -04:00
Raymond Hill
681bd70116
Fix reverse lookup of generic cosmetic exception filters
Reported internally.
2020-06-11 07:18:45 -04:00
Raymond Hill
6926030b68
Expand static parser to better detect invalid syntax
Specifically:

There can't be more than one `redirect` or `csp`
option.

There can be no type specified when there is a
`csp` option.

There must be one single network-related type when
there is a `redirect` option. Since `empty` and
`mp4` imply a `redirect` and a network-related
type, these can't be used along another `redirect`
or network-related type.

Related commit:
- 01b1ed9a98
2020-06-10 12:15:50 -04:00
Raymond Hill
d784fda98b
Fix matching of filters with trailing ^|
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/h08132/can_we_enable_javascript_on_the_homepage_but/ftkxvc5/

The right bound of the match needs to be incremented
when a trailing `^` matches a character.
2020-06-10 09:53:21 -04:00
Raymond Hill
bc7f149252
Minor code review of static parser code 2020-06-09 11:58:27 -04:00
Raymond Hill
08eca13364
Visually emphasize regex-based pattern
To help prevent mistakenly creating regex-based
patterns.
2020-06-08 12:39:31 -04:00
Raymond Hill
58c6baf0ba
Syntax highlight dubious patterns
Network filters with dubious patterns are discarded
by the static network filtering engine.
2020-06-08 08:53:29 -04:00
Raymond Hill
5752ad58b8
Code review of option iterator code
Related commit:
- 01b1ed9a98

Reuse returned item each time the iterator is
restarted.
2020-06-07 19:30:30 -04:00
Raymond Hill
41523d21db
Prepare static parser to better detect invalid filters
Additionally, syntax-color invalid regular expression.
2020-06-07 11:55:27 -04:00
Raymond Hill
7dc962281f
Set max token length on parser for consistent compilation
Reported internally. The issue could cause the logger
to be unable to successfully reverse-lookup a filter
list for a filter which had tokens longer than 6
characters followed by wildcard.

Regression from:
- 01b1ed9a98
2020-06-07 08:50:20 -04:00
Raymond Hill
f869348d1f
Fix string slice extraction from parser
Reported internally.

Regression from:
- 01b1ed9a98

The regression was made apparent be the fact that
AdGuard filter lists have lines ending with the
CR character.
2020-06-07 07:40:00 -04:00
Raymond Hill
0d1a532bfa
Disregard possible trailing carriage return characters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1101
2020-06-06 17:42:21 -04:00
Raymond Hill
b34e6da6ec
Split fetching settings/storage used in Settings pane
Computing storage-used figures can take longer than
usual sometimes when a lot of filter lists are enabled,
and this can cause the Settings pane to take longer to
be filled the first time it is opened. Fetching
settings and storage-used figures separately removes
that potential delay (they were fetched together in
a single Promise.all() call).
2020-06-06 08:45:24 -04:00
Raymond Hill
6633e2635d
Fix dealing with trailing newline characters
Regression from:
- 01b1ed9a98

The new parser needs to be able to deal with trailing
newline characters, which if present will be interpreted
as trailing spaces.
2020-06-05 09:57:48 -04:00
Raymond Hill
01b1ed9a98
Add a new static filtering parser
A new standalone static filtering parser is introduced,
vAPI.StaticFilteringParser. It's purpose is to parse
line of text into representation suitable for
compiling filters. It can additionally serves for
syntax highlighting purpose.

As a side effect, this solves:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1038

This is a first draft, there are more work left to do
to further perfect the implementation and extend its
capabilities, especially those useful to assist filter
authors.

For the time being, this commits break line-continuation
syntax highlighting -- which was already flaky prior to
this commit anyway.
2020-06-04 07:18:54 -04:00
Raymond Hill
46197a11c5
Possibly fix popup document not being found
This is a blind fix attempt, related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1085
2020-05-31 07:08:24 -04:00
Raymond Hill
3508d476ff
Fix bad logger output for miss set of hostnames
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1076
2020-05-29 07:19:23 -04:00
Raymond Hill
a974562f7e
Expand HTML entities in title attribute
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1074
2020-05-27 06:54:11 -04:00
Raymond Hill
cd1fef2d5c
On re-consideration, remove popupPanelGodMode
`filterAuthorMode` is sufficient to enable the
ability to create _allow_ rules from popup panel.
2020-05-25 07:08:02 -04:00
Raymond Hill
8310e91e0e
Fix mixing hostname and entity in domain= option
Reported internally.

Related commit:
- 3c67d2b89f
2020-05-25 07:02:49 -04:00
Raymond Hill
3c67d2b89f
Add support for entity-matching in domain= filter option
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1008

This commit adds support entity-matching in the filter
option `domain=`. Example:

    pattern$domain=google.*

The `*` above is meant to match any suffix from the Public
Suffix List. The semantic is exactly the same as the
already existing entity-matching support in static
extended filtering:

- https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#entity

Additionally, in this commit:

Fix cases where "just-origin" filters of the form `|http*://`
were erroneously normalized to `|http://`. The proper
normalization of `|http*://` is `*`.

Add support to store hostname strings into the character
buffer of a hntrie container. As of commit time, there are
5,544 instances of FilterOriginHit, and 732 instances of
FilterOriginMiss, which filters require storing/matching a
single hostname string. Those strings are now stored in the
character buffer of the already existing origin-related
 hntrie container. (The same approach is used for plain
patterns which are not part of a bidi-trie.)
2020-05-24 10:46:16 -04:00
Raymond Hill
196746386c
Double-tap ctrl key to toggle god mode in popup panel
After many feedback:
- https://github.com/gorhill/uBlock/commit/aec2f81884c5#commitcomment-39385794

This is convenient enough and this still fulfill
the idea of not being able to create mindlessly
allow_ rules.
2020-05-23 19:48:28 -04:00
Raymond Hill
a018937792
Use ctrl-spacebar instead of spacebar to toggle god mode
Related feedback:
- https://github.com/gorhill/uBlock/commit/aec2f81884c5#commitcomment-39385794
2020-05-23 09:26:21 -04:00
Raymond Hill
aec2f81884
Add ability to toggle god mode in popup panel
Pressing spacebar will toggle god mode in popup
panel.

This capability shouldn't encourage people to
misuse _allow_ rules as having to press the
space bar act as an extra necessary step which
purpose is to make the creation of _allow_ rules
more mindful.
2020-05-23 06:37:04 -04:00
Raymond Hill
162e537270
Make the creation of _allow_ rules in panel an opt-in feature
There have been too many examples out there of users
opting-in to "I am an advanced user" and yet still misusing
dynamic filtering by creating _allow_ rules where _noop_
rules should be used.

Creating _allow_ rules has serious consequences as these
override blocking static filters and can potentially
disable other advanced filtering ability such as
HTML filtering and scriptlet injection -- often used
to deal with anti-blocker mechanisms.

The ability to point-and-click to create _allow_ rules
from the popup panel is no longer allowed by default.

An new advanced setting has been added to enable
the ability to create _allow_ rules from the popup
panel, `popupPanelGodMode`, which default to `false`.
Set to `true` to restore ability to set _allow_ rules
from popup panel.

Since the creation of _allow_ rules is especially useful
to filter list authors, to diagnose and narrow down site
breakage as a result of problematic blocking filter,
the creation of _allow_ rules will still be available
when the advanced setting `filterAuthorMode` is `true`.

This change is probably going to be problematic to all
those users who were misusing dynamic filtering by
creating _allow_ rules instead of _noop_ rules -- but
the breakage is going to bring their misusing to their
attention, a positive outcome.
2020-05-22 11:35:44 -04:00
Raymond Hill
5f4e6d80e0
Add ability to lock firewall height to basic pane height
New advanced setting: `popupPanelHeightMode`.
Default value: 0

Set to 1 to force the height of the firewall pane
to be no more than the height of the basic pane.

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/785#issuecomment-622327450
2020-05-22 08:47:51 -04:00
Raymond Hill
a5a447186b
Fix computing the path of nested lists
Regression from:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1034

Nested lists must have their path computed from their
parent list path, not from the path of the root list.
2020-05-20 12:38:41 -04:00
Raymond Hill
9f7e5b621d
Add new advanced setting: uiStyles
Default to `unset`.

To allow users to bypass uBO's default CSS styles in
case they are causing issues to specific users. It is
the responsibility of the user to ensure the value of
`uiStyles` contains valid CSS property declarations.
uBO will assign the value to `document.body.style.cssText`.

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

For example, in the case of the issue above, one could
set `uiStyles` to `font-family: sans-serif` to force uBO
to the system font for its user interface.
2020-05-19 10:33:36 -04:00
Raymond Hill
5229e0c810
Ensure either .desktop or .mobile class is set
One of these must always be present. This commit
fixes a theoretical case where neither of these
classes are set on the body element.
2020-05-19 10:29:09 -04:00
Raymond Hill
2237d97466
Even more fine tuning of UI as per feedback
Fix unstyled checkbox in "Filter lists" pane.
Related feedback:

https://github.com/uBlockOrigin/uBlock-issues/issues/1027#issuecomment-629780098

Hopefully fix glitchy popup panel when opened
from the extension icon. By default the panel is
configured to be rendered in landscape. It will be
toggled programmatically to portrait mode when
either the environment is mobile or the viewport
is horizontally constrained. Related feedback:

https://github.com/uBlockOrigin/uBlock-issues/issues/1027#issuecomment-629712393

New layout for rendering the statistics text
strings in landscape mode, so as to avoid text
wrapping and to allow a slightly narrower basic
pane. Related discussion:

https://github.com/uBlockOrigin/uBlock-issues/issues/1027#issuecomment-629785966
2020-05-17 08:49:37 -04:00
Raymond Hill
5c7aa850dc
More fine tuning of new UI as per feedback
Position the backup/restore/reset buttons at the
bottom in Settings pane. Related feedback:

https://github.com/gorhill/uBlock/commit/5bee33253f45#commitcomment-39221329

Use a fixed with for the fireall pane. Related
feedback:

https://github.com/uBlockOrigin/uBlock-issues/issues/1027#issuecomment-629668065

Fall back to a polyfill compact notation when
rednering large numbers in popup panel when the
required Intl.NumberFormat API is not fully
supported, at the expense of not being i18n-
compliant. Related discussion:

https://github.com/uBlockOrigin/uBlock-issues/issues/1027#issuecomment-629696676
2020-05-16 17:51:01 -04:00
Raymond Hill
8859d4352f
Restore ability to set popup panel font size in advanced settings
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/397

Issue above will require non-trivial changes, so for
now users who prefer smaller/larger popup panel can
fall back on advanced setting `popupFontSize`:

https://github.com/gorhill/uBlock/wiki/Advanced-settings#popupfontsize
2020-05-16 07:36:03 -04:00
Raymond Hill
8ceed3d4ca
Fix !#include directive when loading from packaged lists
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1034
2020-05-15 18:06:14 -04:00
Raymond Hill
4fa5c6b88e
Fix uselessly allocating one extra WASM page
spotted as a result of stepping in the code. The issue
is that a uBP "page size" might differ from a WASM
page size, which is always 65536 bytes.
2020-05-15 12:03:05 -04:00
Raymond Hill
f060bb5382
Replace FilterPlainHostname with composite filter
FilterPlainHostname, an atomic filter unit, has been
removed and is being replaced with a composite filter
made of a pattern filter and a filter which test
hostname boundaries.

Doing so enables filters formerly being represented
by FilterPlainHostname to be now represented as a
plain pattern, and thus to be potentially stored in
a bidi-trie.

Comparing the new filter histogram with the previous
one:

FilterPatternPlain      24612   26432    1820
FilterComposite         17656   17125    -531
FilterPlainTrie Content 12977   13519     542
FilterPlainHostname      2904       0   -2904
FilterBucket             2121    1961    -160
FilterPlainTrie          1418    1578     160

Which means:
- An extra 542 patterns could be stored in bidi-tries
- There are 531 less composite filters needed
- An extra 160 buckets could be aggregated into 160
  bidi-trie

Memory-wise, it's a marginal gain (as per Chromium's
Javascript VM instance figure) -- i.e. not worth
talking about). CPU-wise, no measurable difference.

The benefit is that I consider this conceptually
simplifies slightly the static network filtering
code base.
2020-05-15 11:00:16 -04:00
Raymond Hill
3d3cd58d9f
Properly auto-toggle on firewall pane [regression]
... when enabling advanced user mode. A regression
caused the pane to be toggled to hidden state instead
of being toggled to shown state.
2020-05-12 12:08:32 -04:00
Raymond Hill
19e6936ed9
Do not show per-site switches at first install time
I meant to not show the per-site switches by default
at first install. I caught this misconfiguration after
testing a first-install scenario.
2020-05-12 10:11:24 -04:00
Raymond Hill
f842ab6d3c
Add new scriptlet to allow blocking Amazon's apstag.js
Related issues:
- https://github.com/NanoMeow/QuickReports/issues/3717
- https://www.reddit.com/r/uBlockOrigin/comments/ghjqph/

The specific issue on the mentioned site is that the
site's code expect `window.apstag.fetchBids` to call
client-supplied function. The new scriptlet defuse this
by calling the client code with an empty array.
2020-05-11 07:57:14 -04:00
Raymond Hill
c42f23c131
Rerrange popup panel layout initializing code
Specifically, the sticky controls box is re-parented
pre-emptively instead of waiting for the decision as
to whether the panel must be toggled into a vertical
layout mode.
2020-05-08 09:16:20 -04:00
Raymond Hill
b226873bdb
Wait a bit longer before testing viewport width 2020-05-07 15:42:30 -04:00
Raymond Hill
2d960cf530
Test against window.innerWidth to toggle vertical layout 2020-05-07 15:24:39 -04:00
Raymond Hill
80b758e18d
Let the platform pick the default suspend state at launch
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1004

The fix is trivial enough that I feel confident to make
it part of current RC cycle. There are many reports of
block page at launch on Chromium.

The fix is to let the platform pick it's natural suspend
state rather than force it. Once advanced settings are
read, the suspend state will for toggled only if
`suspendTabsUntilReady` is either `yes` or `no`. This
there should no longer be blocked page on Chromium at
launch when using default settings.

Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/gac2h8/
2020-05-06 20:30:58 -04:00
Raymond Hill
563ba9136c
Improve heuristic to toggle panel to vertical layout
By using a larger tolerance.

Also, ensure that the hover visuals are still
being used in vertical layout mode on non-mobile
devices.
2020-05-06 10:39:03 -04:00
Raymond Hill
6c90cdae3a
Avoid fractional pixel in viewport height
Fractional pixel could lead to minor scrollbar
glitch -- reported internally.
2020-05-05 07:08:38 -04:00
Raymond Hill
c7d196d472
Re-design document-blocked page as per feedback
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1005

There is probably more work to do regarding the
shown URL -- it might be better to truncate it
on small screen display since it can be quite
long sometimes.
2020-05-04 12:41:10 -04:00
Raymond Hill
002a825891
Add tolerance to popup panel when checking viewport width
I meant to add this to last commit:
- a54718862c
2020-05-03 09:26:19 -04:00
Raymond Hill
a54718862c
Maybe fix rare spurious viewport width test in popup panel
In rare instances -- though it definitely happens
eventually -- the popup panel viewport width is seen as
insufficiently wide enough and as a result the popup panel
is toggled into vertical-layout mode.

The added code uses animation frames to delay the
code testing the viewport width. Hopefully this will
work.
2020-05-03 09:18:53 -04:00