Skip to content

Commit 7494eaf

Browse files
committed
Improve parse-properties-to-match scriptlet helper
Related issue: uBlockOrigin/uBlock-discussions#831 (comment) If the property name contains unexpected characters, assume that the `:` is not a separator.
1 parent 89e4413 commit 7494eaf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/js/resources/scriptlets.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,12 @@ function parsePropertiesToMatch(propsToMatch, implicit = '') {
598598
if ( propsToMatch === undefined || propsToMatch === '' ) { return needles; }
599599
const options = { canNegate: true };
600600
for ( const needle of safe.String_split.call(propsToMatch, /\s+/) ) {
601-
const [ prop, pattern ] = safe.String_split.call(needle, ':');
601+
let [ prop, pattern ] = safe.String_split.call(needle, ':');
602602
if ( prop === '' ) { continue; }
603+
if ( pattern !== undefined && /[^$\w -]/.test(prop) ) {
604+
prop = `${prop}:${pattern}`;
605+
pattern = undefined;
606+
}
603607
if ( pattern !== undefined ) {
604608
needles.set(prop, safe.initPattern(pattern, options));
605609
} else if ( implicit !== '' ) {

0 commit comments

Comments
 (0)