mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-15 07:22:28 +02:00
Auto-escape commas in removeparam's regexes
Related feedback: - https://github.com/uBlockOrigin/uBlock-issues/issues/760#issuecomment-951146371 This is a quick fix, some refactoring necessary for a more comprehensive fix to all such issues.
This commit is contained in:
parent
f5001c03aa
commit
c136c7b454
@ -208,25 +208,30 @@ CodeMirror.defineMode('ubo-static-filtering', function() {
|
||||
return style || 'value';
|
||||
};
|
||||
|
||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/760#issuecomment-951146371
|
||||
// Quick fix: auto-escape commas.
|
||||
const colorNetOptionSpan = function(stream) {
|
||||
const bits = parser.slices[parserSlot];
|
||||
if ( (bits & parser.BITComma) !== 0 ) {
|
||||
netOptionValueMode = false;
|
||||
stream.pos += parser.slices[parserSlot+2];
|
||||
parserSlot += 3;
|
||||
return 'def strong';
|
||||
const [ slotBits, slotPos, slotLen ] =
|
||||
parser.slices.slice(parserSlot, parserSlot+3);
|
||||
if ( (slotBits & parser.BITComma) !== 0 ) {
|
||||
if ( /^,\d*?\}/.test(parser.raw.slice(slotPos)) === false ) {
|
||||
netOptionValueMode = false;
|
||||
stream.pos += slotLen;
|
||||
parserSlot += 3;
|
||||
return 'def strong';
|
||||
}
|
||||
}
|
||||
if ( netOptionValueMode ) {
|
||||
return colorNetOptionValueSpan(stream, bits);
|
||||
return colorNetOptionValueSpan(stream, slotBits);
|
||||
}
|
||||
if ( (bits & parser.BITTilde) !== 0 ) {
|
||||
stream.pos += parser.slices[parserSlot+2];
|
||||
if ( (slotBits & parser.BITTilde) !== 0 ) {
|
||||
stream.pos += slotLen;
|
||||
parserSlot += 3;
|
||||
return 'keyword strong';
|
||||
}
|
||||
if ( (bits & parser.BITEqual) !== 0 ) {
|
||||
if ( (slotBits & parser.BITEqual) !== 0 ) {
|
||||
netOptionValueMode = true;
|
||||
stream.pos += parser.slices[parserSlot+2];
|
||||
stream.pos += slotLen;
|
||||
parserSlot += 3;
|
||||
return 'def';
|
||||
}
|
||||
|
@ -1884,9 +1884,9 @@ const BITUnderscore = 1 << 22;
|
||||
const BITBrace = 1 << 23;
|
||||
const BITPipe = 1 << 24;
|
||||
const BITTilde = 1 << 25;
|
||||
const BITOpening = 1 << 27;
|
||||
const BITClosing = 1 << 28;
|
||||
const BITUnicode = 1 << 29;
|
||||
const BITOpening = 1 << 26;
|
||||
const BITClosing = 1 << 27;
|
||||
const BITUnicode = 1 << 28;
|
||||
// TODO: separate from character bits into a new slice slot.
|
||||
const BITIgnore = 1 << 30;
|
||||
const BITError = 1 << 31;
|
||||
@ -2359,6 +2359,9 @@ const Span = class {
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/760#issuecomment-951146371
|
||||
// Quick fix: auto-escape commas.
|
||||
|
||||
const NetOptionsIterator = class {
|
||||
constructor(parser) {
|
||||
this.parser = parser;
|
||||
@ -2426,8 +2429,9 @@ const NetOptionsIterator = class {
|
||||
if ( hasBits(bits, BITComma) ) {
|
||||
if ( this.interactive && (i === lopt || slices[i+2] > 1) ) {
|
||||
slices[i] |= BITError;
|
||||
} else if ( /^,\d*?\}/.test(this.parser.raw.slice(slices[i+1])) === false ) {
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if ( lval === 0 && hasBits(bits, BITEqual) ) { lval = i; }
|
||||
i += 3;
|
||||
@ -2551,7 +2555,7 @@ const NetOptionsIterator = class {
|
||||
}
|
||||
}
|
||||
}
|
||||
// `queryprune=`: only for network requests.
|
||||
// `removeparam=`: only for network requests.
|
||||
{
|
||||
const i = this.tokenPos[OPTTokenQueryprune];
|
||||
if ( i !== -1 ) {
|
||||
|
Loading…
Reference in New Issue
Block a user