1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 09:37:12 +02:00

Minor code review

This commit is contained in:
Raymond Hill 2023-10-17 23:10:59 -04:00
parent 31bdc9ef0d
commit b98ee0f442
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -610,10 +610,11 @@ class argListParser {
this.reWhitespaceStart = /^\s+/; this.reWhitespaceStart = /^\s+/;
this.reWhitespaceEnd = /\s+$/; this.reWhitespaceEnd = /\s+$/;
this.reOddTrailingEscape = /(?:^|[^\\])(?:\\\\)*\\$/; this.reOddTrailingEscape = /(?:^|[^\\])(?:\\\\)*\\$/;
this.reUnescapeDoubleQuotes = /((?:^|[^\\])(?:\\\\)*)\\"/g; this.reEscapedDoubleQuote = /((?:^|[^\\])(?:\\\\)*)\\"/g;
this.reUnescapeSingleQuotes = /((?:^|[^\\])(?:\\\\)*)\\'/g; this.reEscapedSingleQuote = /((?:^|[^\\])(?:\\\\)*)\\'/g;
this.reUnescapeBackticks = /((?:^|[^\\])(?:\\\\)*)\\`/g; this.reEscapedBacktick = /((?:^|[^\\])(?:\\\\)*)\\`/g;
this.reUnescapeSeparator = new RegExp(`((?:^|[^\\\\])(?:\\\\\\\\)*)\\\\${this.separatorChar}`, 'g'); this.reEscapedSeparator = new RegExp(`((?:^|[^\\\\])(?:\\\\\\\\)*)\\\\${this.separatorChar}`, 'g');
this.unescapedSeparator = `$1${this.separatorChar}`;
} }
nextArg(pattern, beg = 0) { nextArg(pattern, beg = 0) {
const len = pattern.length; const len = pattern.length;
@ -649,18 +650,18 @@ class argListParser {
switch ( this.actualSeparatorCode ) { switch ( this.actualSeparatorCode ) {
case 0x22 /* " */: case 0x22 /* " */:
if ( s.includes('"') === false ) { return; } if ( s.includes('"') === false ) { return; }
return s.replace(this.reUnescapeDoubleQuotes, '$1"'); return s.replace(this.reEscapedDoubleQuote, '$1"');
case 0x27 /* ' */: case 0x27 /* ' */:
if ( s.includes("'") === false ) { return; } if ( s.includes("'") === false ) { return; }
return s.replace(this.reUnescapeSingleQuotes, "$1'"); return s.replace(this.reEscapedSingleQuote, "$1'");
case 0x60 /* ` */: case 0x60 /* ` */:
if ( s.includes('`') === false ) { return; } if ( s.includes('`') === false ) { return; }
return s.replace(this.reUnescapeBackticks, '$1`'); return s.replace(this.reEscapedBacktick, '$1`');
default: default:
break; break;
} }
if ( s.includes(this.separatorChar) === false ) { return; } if ( s.includes(this.separatorChar) === false ) { return; }
return s.replace(this.reUnescapeSeparator, `$1${this.separatorChar}`); return s.replace(this.reEscapedSeparator, this.unescapedSeparator);
} }
leftWhitespaceCount(s) { leftWhitespaceCount(s) {
const match = this.reWhitespaceStart.exec(s); const match = this.reWhitespaceStart.exec(s);