1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-04 01:59:38 +02:00

Escape attribute values

Related issues:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2284#issuecomment-1265417399
This commit is contained in:
Raymond Hill 2022-10-04 08:11:31 -04:00
parent 76fe28333d
commit 24273d2c94
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 7 additions and 2 deletions

View File

@ -40,7 +40,10 @@ let hintHelperRegistered = false;
CodeMirror.defineMode('ubo-static-filtering', function() {
if ( StaticFilteringParser instanceof Object === false ) { return; }
const parser = new StaticFilteringParser({ interactive: true });
const parser = new StaticFilteringParser({
interactive: true,
nativeCssHas: vAPI.webextFlavor.env.includes('native_css_has'),
});
const reURL = /\bhttps?:\/\/\S+/;
const rePreparseDirectives = /^!#(?:if|endif|include )\b/;

View File

@ -1586,7 +1586,7 @@ Parser.prototype.SelectorCompiler = class {
if ( typeof value !== 'string' ) {
value = data.value.name;
}
out.push(`[${name}${data.matcher}"${value}"]`);
out.push(`[${name}${data.matcher}"${CSS.escape(value)}"]`);
break;
}
case 'ClassSelector':
@ -1858,6 +1858,7 @@ Parser.prototype.SelectorCompiler = class {
// backslash characters.
// Remove potentially present quotes before processing.
compileText(s) {
if ( s === '' ) { return; }
s = this.extractArg(s);
const match = this.reParseRegexLiteral.exec(s);
let regexDetails;
@ -1950,6 +1951,7 @@ Parser.prototype.SelectorCompiler = class {
}
compileAttrList(s) {
if ( s === '' ) { return; }
const attrs = s.split('\s*,\s*');
const out = [];
for ( const attr of attrs ) {