Trim end of class tokens in generic cosmetic filtering's surveyor

Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/3257
This commit is contained in:
Raymond Hill 2024-05-28 18:42:06 -04:00
parent ce7806e3f1
commit 8ea1bac80b
No known key found for this signature in database
GPG key ID: 25E1490B761470C2
2 changed files with 6 additions and 2 deletions

View file

@ -89,8 +89,10 @@ const uBOL_classesFromNode = (node, out) => {
end = s.indexOf(' ', beg);
if ( end === beg ) { continue; }
if ( end === -1 ) { end = len; }
out.push(hashFromStr(0x2E /* '.' */, s.slice(beg, end)));
const token = s.slice(beg, end).trimEnd();
beg = end;
if ( token.length === 0 ) { continue; }
out.push(hashFromStr(0x2E /* '.' */, token));
}
};

View file

@ -1016,8 +1016,10 @@ vAPI.DOMFilterer = class {
end = s.indexOf(' ', beg);
if ( end === beg ) { continue; }
if ( end === -1 ) { end = len; }
const hash = hashFromStr(0x2E /* '.' */, s.slice(beg, end));
const token = s.slice(beg, end).trimEnd();
beg = end;
if ( token.length === 0 ) { continue; }
const hash = hashFromStr(0x2E /* '.' */, token);
if ( queriedHashes.has(hash) ) { continue; }
queriedHashes.add(hash);
out.push(hash);