1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-08 12:57:57 +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.reWhitespaceEnd = /\s+$/;
this.reOddTrailingEscape = /(?:^|[^\\])(?:\\\\)*\\$/;
this.reUnescapeDoubleQuotes = /((?:^|[^\\])(?:\\\\)*)\\"/g;
this.reUnescapeSingleQuotes = /((?:^|[^\\])(?:\\\\)*)\\'/g;
this.reUnescapeBackticks = /((?:^|[^\\])(?:\\\\)*)\\`/g;
this.reUnescapeSeparator = new RegExp(`((?:^|[^\\\\])(?:\\\\\\\\)*)\\\\${this.separatorChar}`, 'g');
this.reEscapedDoubleQuote = /((?:^|[^\\])(?:\\\\)*)\\"/g;
this.reEscapedSingleQuote = /((?:^|[^\\])(?:\\\\)*)\\'/g;
this.reEscapedBacktick = /((?:^|[^\\])(?:\\\\)*)\\`/g;
this.reEscapedSeparator = new RegExp(`((?:^|[^\\\\])(?:\\\\\\\\)*)\\\\${this.separatorChar}`, 'g');
this.unescapedSeparator = `$1${this.separatorChar}`;
}
nextArg(pattern, beg = 0) {
const len = pattern.length;
@ -649,18 +650,18 @@ class argListParser {
switch ( this.actualSeparatorCode ) {
case 0x22 /* " */:
if ( s.includes('"') === false ) { return; }
return s.replace(this.reUnescapeDoubleQuotes, '$1"');
return s.replace(this.reEscapedDoubleQuote, '$1"');
case 0x27 /* ' */:
if ( s.includes("'") === false ) { return; }
return s.replace(this.reUnescapeSingleQuotes, "$1'");
return s.replace(this.reEscapedSingleQuote, "$1'");
case 0x60 /* ` */:
if ( s.includes('`') === false ) { return; }
return s.replace(this.reUnescapeBackticks, '$1`');
return s.replace(this.reEscapedBacktick, '$1`');
default:
break;
}
if ( s.includes(this.separatorChar) === false ) { return; }
return s.replace(this.reUnescapeSeparator, `$1${this.separatorChar}`);
return s.replace(this.reEscapedSeparator, this.unescapedSeparator);
}
leftWhitespaceCount(s) {
const match = this.reWhitespaceStart.exec(s);