Skip to content

Commit

Permalink
Improve parse-properties-to-match scriptlet helper
Browse files Browse the repository at this point in the history
Related issue:
uBlockOrigin/uBlock-discussions#831 (comment)

If the property name contains unexpected characters, assume that
the `:` is not a separator.
  • Loading branch information
gorhill committed Dec 21, 2024
1 parent 89e4413 commit 7494eaf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/js/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,12 @@ function parsePropertiesToMatch(propsToMatch, implicit = '') {
if ( propsToMatch === undefined || propsToMatch === '' ) { return needles; }
const options = { canNegate: true };
for ( const needle of safe.String_split.call(propsToMatch, /\s+/) ) {
const [ prop, pattern ] = safe.String_split.call(needle, ':');
let [ prop, pattern ] = safe.String_split.call(needle, ':');
if ( prop === '' ) { continue; }
if ( pattern !== undefined && /[^$\w -]/.test(prop) ) {
prop = `${prop}:${pattern}`;
pattern = undefined;
}
if ( pattern !== undefined ) {
needles.set(prop, safe.initPattern(pattern, options));
} else if ( implicit !== '' ) {
Expand Down

0 comments on commit 7494eaf

Please sign in to comment.