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

Exceptions do not work when processing requests with long paths (kinopoisk.ru) #1207

Closed
dimisa-RUAdList opened this issue Aug 15, 2020 · 7 comments
Labels
bug Something isn't working fixed issue has been addressed

Comments

@dimisa-RUAdList
Copy link

Google Chrome 84.0.4147.125
uBlock Origin 1.28.4 default + RU AdList

Firefox 79.0
uBlock Origin 1.29.0 default + RU AdList

How to reproduce
Open: https://www.kinopoisk.ru/media/video/4002311/
Refresh the page several times.

Regular expression /^https?://www\.kinopoisk\.ru/[^\s]{300,}/$popup,subdocument,domain=www.kinopoisk.ru
will block a frame with a path like:
https://www.kinopoisk.ru/1t5O5H170/4960867nE/VxgT4Bsgza-uFjtqf9PVZqHzLX3DZ0QOaCi0p46vBoy_CbkK9W5sZpCtbbiIhDypWO6GoMgok-5VHCapV2ogZJekA-xCSMWGrhJvB2fStWLFg-m8g_vcElVMIDfaE4KsmyhNcj2ybIaUKJ1skIFkTZzirnw0qGsiQQQyPecGSCjrDBekE9R9Cr4SP6OTKkyKnevFbc-XSNbBxCQnIoNKLFfw0fL1NnyiDCwNtHTdkIEMPp447AhD1mGMHmmrQgDYkxRvrNNcSWLC_u-fU7LE7tHTWRFLz8hOATSIBzbTdnjvzAn-CcYMLsQ4cbTIjWDZ8L4KsCDYj4rBcL5dczLgqLuM42B3JKlimv4DX-PCpAa5Sz3Nn3tU8tUwIE_mc2J4U9TN-slibJIoZAHs0DlUCeSOAojIDL8ybSTOHU_qQCCjFBeEr3xVQjaCR-NLLny-zfsxVRvLLG4VSOyH6k92UJOorRKlHtTutKBdNFDpJAXkRvY8JJgL2oXw-kUnYtB0GwzTkD9MdTLahhtbd8JUkinj_ZUL37CKWTRoaxo7AjwvnGHW6brwDsxk_SxcURA1_IL2NOysa07dpJZl_xLAmDcgk3gjyEVuzv7_M_9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VIpHpw6eITB6FAZrLUMCi4YWDCPhvk4_lnzejhka9xPrPfEXTKuEhcPl1qMChFnsXkbw8heYQg0x3J3HgCDSO3SaYYEDvjMuSh4dSC19H6ywMzwK6bxeD5tR8rU5IsgHyiLVFV-copvd5e23MoZ_7Wpx9dwUhWEfOOOn8r4ozgxIkHG0Jqo9MU8RHGgRWBWunikJKtShVgE/dist/embed.html?frameId=frame32706

In this case, the exception @@||www.kinopoisk.ru^*/dist/embed.html?frameId=$subdocument,domain=www.kinopoisk.ru is not working.

This problem does not exist when using Adblock Plus.

@mapx-
Copy link
Contributor

mapx- commented Aug 15, 2020

parsing correctly the first 2096 bytes

@uBlock-user uBlock-user added the bug Something isn't working label Aug 15, 2020
@mapx-
Copy link
Contributor

mapx- commented Aug 15, 2020

maybe the bug was introduced here:
uBlock-LLC/uBlock@ab15132

and currently the code in utils.js

    // https://github.com/chrisaljoudi/uBlock/issues/1118
    // We limit to a maximum number of tokens.

    _tokenize(encodeInto) {
        const tokens = this._tokens;
        let url = this._urlOut;
        let l = url.length;
        if ( l === 0 ) { return 0; }
        if ( l > 2048 ) {
            url = url.slice(0, 2048);
            l = 2048;
        }

@dimisa-RUAdList
Copy link
Author

For now, I've disabled the blocking rule for uBlock Origin users so that they can use the site normally. But I think there are other cases when the rules do not work correctly.

@gorhill
Copy link
Member

gorhill commented Aug 15, 2020

This isn't trivial to fix, because this involves revisiting a lot of optimizations, including in WASM modules. With WASM, buffer size have to be preset, so I can't just change the slice value to fix this.

A workaround for when the target URL to match may be longer than the buffer size (2048 characters) is to force the filter to be parsed as a generic one, like so:

@@||www.kinopoisk.ru^**/dist/embed.html?frameId=$subdocument,domain=www.kinopoisk.ru

Without the extra wildcard, the filter is optimized as a ^*-separated dual patterns. Simply adding a wildcard defuse this optimization and the pattern is then evaluated as a plain generic filter representation -- no typed array involved. I don't think the extra wildcard would be an issue with ABP.

@dimisa-RUAdList
Copy link
Author

Yes, it works.
Fix

@WizardShotTheFood
Copy link

I ran into the same issue with a chatbro.com embed. Gorhill's workaround worked there as well.

gorhill added a commit to gorhill/uBlock that referenced this issue Dec 6, 2021
Turns out the various benchmarks show no benefits when compiling
filters whose pattern contains a single wildcard character into
specialized classes which threat the pattern as two sub-patterns,
and actually there is a slight improvement in performance as per
benchamrks when treating these patterns as generic ones.

This also fixes the following related issue:
- uBlockOrigin/uBlock-issues#1207
@gwarser
Copy link

gwarser commented Dec 6, 2021

/\.clstorage\.net/[^\s]{300,}/$popup,subdocument,domain=www.kinopoisk.ru
@@||clstorage.net^*/dist/embed.html?frameId=$subdocument,domain=www.kinopoisk.ru

@gwarser gwarser closed this as completed Dec 6, 2021
@gwarser gwarser added the fixed issue has been addressed label Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed issue has been addressed
Projects
None yet
Development

No branches or pull requests

6 participants