Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failures on options parsing if a filter has $ character later than actual options index #3885

Closed
seia-soto opened this issue Apr 5, 2024 · 0 comments · Fixed by #3887
Closed

Comments

@seia-soto
Copy link
Member

seia-soto commented Apr 5, 2024

Internals

||www.youtube.com/playlist?list=$xhr,1p,replace=/("trackingParam":"kx_fmPxhoPZR)[-_0-9A-Za-z]{150}[-_0-9A-Za-z]+?([-_0-9A-Za-z]{55}lLKPQ-SS"\})/\$1\$2/

The above filter has a dollar sign later than actual options index. This causes the internal logic to confuse where is actual options index is:

// filters/network.ts
// filter$options == Options
// ^     ^
// |     |
// |     optionsIndex
// filterIndexStart
const optionsIndex: number = line.lastIndexOf('$');

The following REPL shows how the logic failed:

C:\Users\aa\local\repos\adblocker\packages\adblocker>node
Welcome to Node.js v20.11.0.
Type ".help" for more information.
> const filter = String.raw`||www.youtube.com/playlist?list=$xhr,1p,replace=/("trackingParam":"kx_fmPxhoPZR)[-_0-9A-Za-z]{150}[-_0-9A-Za-z]+?([-_0-9A-Za-z]{55}lLKPQ-SS"\})/\$1\$2/`;
undefined
> filter.lastIndexOf('$')
148
> filter.slice(filter.lastIndexOf('$') + 1)
'2/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant