AdguardTeam / FiltersCompiler

A tool that compiles & validates filters
GNU Lesser General Public License v3.0
52 stars 12 forks source link

Throw when converting a scriptlet with path option to uBO syntax #182

Closed gorhill closed 1 year ago

gorhill commented 1 year ago

uBO's scriptlet syntax does not support AdGuard's [path=...] option.

To prevent conversion to invalid filter, the conversion will error when attempting to convert an AdGuard scriptlet with a path option present.

Related issue:

slavaleleka commented 1 year ago

@gorhill could you please also add some tests for it?

gorhill commented 1 year ago

Not sure how is thebest way to test this. I implemented using a throw because the code in there is ready to deal with exception:

https://github.com/AdguardTeam/FiltersCompiler/blob/master/src/main/converter.js#L33-L44

In which case if I understand correctly, the filter will be dropped.

The test for scriptlets with path modifier is at:

https://github.com/AdguardTeam/FiltersCompiler/blob/master/src/test/converter.test.js#L573-L581

But not sure how to test for expected exception.

gorhill commented 1 year ago

I think I understand better how this is supposed to work, I will modify the fix.