From 7494eaf621c60dc8ddb901deacc74af5cc329380 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sat, 21 Dec 2024 11:27:03 -0500 Subject: [PATCH] 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. --- src/js/resources/scriptlets.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/js/resources/scriptlets.js b/src/js/resources/scriptlets.js index a460f3fb7..36d521923 100644 --- a/src/js/resources/scriptlets.js +++ b/src/js/resources/scriptlets.js @@ -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 !== '' ) {