uBlockOrigin / uBlock-issues

This is the community-maintained issue tracker for uBlock Origin
https://github.com/gorhill/uBlock
944 stars 80 forks source link

`''` value is no longer supported for `set` / `set-attr`? #2729

Closed krystian3w closed 1 year ago

krystian3w commented 1 year ago

Prerequisites

I tried to reproduce the issue when...

Description

I detected today bug in Dev cycle about support empty "value" (I mean '') in scriptlets.

example scriptlets groups:

! cusor should be changed, but didn't.

! valid in AdGuard for some reason:
example.*#%#//scriptlet("set-attr", "body, body  *", "disabled", "")
! standard css:
example.*##[disabled]:style(cursor: not-allowed !important;)
example.*##[disabled] [disabled]:style(color: gray !important; cursor: grab !important; user-select: none !important;)
! https://testcases.agrd.dev/Filters/scriptlet-rules/test-scriptlet-rules.html?testId=07a35257
! /\+js\(set,.*, ?''\)/ - 94+ uBo ads, ~3  uBo privacy, ~1 uBo unbreak
!
! most to pass tests other than one specific set-constant:
testcases.agrd.dev,surge.sh###subscribe-to-test-scriptlet-rules-filter
testcases.agrd.dev,surge.sh##+js(set, setConstantAGSyntax, true)
testcases.agrd.dev,surge.sh##+js(set, setConstantUBOSyntax, true)
testcases.agrd.dev,surge.sh##+js(set, trueProp, true)
testcases.agrd.dev,surge.sh##+js(set, falseProp, false)
testcases.agrd.dev,surge.sh##+js(set, undefinedProp, undefined)
testcases.agrd.dev,surge.sh##+js(set, nullProp, null)
testcases.agrd.dev,surge.sh##+js(set, noopFuncProp, noopFunc)
testcases.agrd.dev,surge.sh##+js(set, trueFuncProp, trueFunc)
testcases.agrd.dev,surge.sh##+js(set, falseFuncProp, falseFunc)
testcases.agrd.dev,surge.sh##+js(set, numberProp, 111)
! failed:
testcases.agrd.dev,surge.sh##+js(set, emptyStringProp, '')
! invalid:
testcases.agrd.dev,surge.sh##+js(set, emptyStringProp, "")
! reset of test to mark as passed
testcases.agrd.dev,surge.sh##+js(set, illegalNumberProp, 32768)

I guess from commit about extend support AG syntax.


By dumb regex:

/\+js\(set,.*, ?''\)/

I found 96+ usefull situations where are needed support to avoid rewrite to other scriptlet or network filtering.

A specific URL where the issue occurs.

https://testcases.agrd.dev/Filters/scriptlet-rules/test-scriptlet-rules.html?testId=07a35257

https://example.com/ https://example.org/

Steps to Reproduce

  1. copy filters from description
  2. paste to "My filters" and save
  3. open AdGuard test page (or example.org)

Expected behavior

Actual behavior


Both without new quoting:

! invalid in AdGuard now for MV2 WebExtension:
example.*#%#//scriptlet("set-attr", "body, body  *", "disabled", "''")
testcases.agrd.dev,surge.sh##+js(set, emptyStringProp, "''")
testcases.agrd.dev,surge.sh##+js(trusted-set, emptyStringProp, "''")

uBO version

1.50.1b16

Browser name and version

Chrome 109

Operating System and version

Windows 7 Pro

krystian3w commented 1 year ago

Moved to set-attr origin issue.

Also funny is correlation:

<link href="foo.css" disabled>

In that method possible disable run css form file at all in Firefox/Chrome by:

foo.bar##+js(set-attr, link, disabled, true)
krystian3w commented 1 year ago

Also fine is for uBo only:

testcases.agrd.dev,surge.sh##+js(set, emptyStringProp, "''")
testcases.agrd.dev,surge.sh##+js(trusted-set, emptyStringProp, "''")

But who start correct/duplicate in ~96 uBo places after publish new parser as stable.

krystian3w commented 1 year ago

https://github.com/gorhill/uBlock/commit/6e78ee096a8c035f5819325d5b6465b915008c60

gorhill commented 1 year ago

testcases.agrd.dev

Cool stuff. Do you know if there is a filter list somewhere to test all filters?


Never mind, found this: https://github.com/AdguardTeam/TestCases/blob/master/public/Filters/scriptlet-rules/test-scriptlet-rules.txt

krystian3w commented 1 year ago

Maybe missed in aliases:

foo#%#//scriptlet("prevent-bab")

Or test are outdated after bab preventing logic was changed to use two different surrogates.