Improve parse-properties-to-match scriptlet helper

Related issue:
https://github.com/uBlockOrigin/uBlock-discussions/discussions/831#discussioncomment-11637436

If the property name contains unexpected characters, assume that
the `:` is not a separator.
This commit is contained in:
Raymond Hill 2024-12-21 11:27:03 -05:00
parent 89e44131a0
commit 7494eaf621
No known key found for this signature in database
GPG key ID: 25E1490B761470C2

View file

@ -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 !== '' ) {