1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-16 15:33:38 +01:00

Improve validate-constant scriptlet helper

Add support for `json:`-prefixed values.
This commit is contained in:
Raymond Hill 2024-08-29 13:47:48 -04:00
parent b1f28b4ce0
commit ae5dc6299e
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -531,7 +531,9 @@ function validateConstantFn(trusted, raw, extraArgs = {}) {
if ( isNaN(raw) ) { return; }
if ( Math.abs(raw) > 0x7FFF ) { return; }
} else if ( trusted ) {
if ( raw.startsWith('{') && raw.endsWith('}') ) {
if ( raw.startsWith('json:') ) {
try { value = safe.JSON_parse(raw.slice(5)); } catch(ex) { return; }
} else if ( raw.startsWith('{') && raw.endsWith('}') ) {
try { value = safe.JSON_parse(raw).value; } catch(ex) { return; }
}
} else {