Skip to content

Commit

Permalink
Trim end of class tokens in generic cosmetic filtering's surveyor
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed May 28, 2024
1 parent ce7806e commit 8ea1bac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion platform/mv3/extension/js/scripting/css-generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
};

Expand Down
4 changes: 3 additions & 1 deletion src/js/contentscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8ea1bac

Please sign in to comment.