This commit is contained in:
Cohee 2024-11-24 19:37:20 -06:00 committed by GitHub
commit f93e7d89d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 8 deletions

View File

@ -1040,9 +1040,9 @@ export class SlashCommandParser {
/**@type {SlashCommandUnnamedArgumentAssignment}*/
let assignment = new SlashCommandUnnamedArgumentAssignment();
assignment.start = this.index;
if (!split && this.testQuotedValue()) {
if (!split && this.testEscapedQuotedValue()) {
// if the next bit is a quoted value, take the whole value and gather contents as a list
assignment.value = this.parseQuotedValue();
assignment.value = this.parseEscapedQuotedValue();
assignment.end = this.index;
isList = true;
listValues.push(assignment);
@ -1054,9 +1054,9 @@ export class SlashCommandParser {
if (split && splitCount && listValues.length >= splitCount) {
// the split count has just been reached: stop splitting, the rest is one singular value
split = false;
if (this.testQuotedValue()) {
if (this.testEscapedQuotedValue()) {
// if the next bit is a quoted value, take the whole value
assignment.value = this.parseQuotedValue();
assignment.value = this.parseEscapedQuotedValue();
assignment.end = this.index;
listValues.push(assignment);
listQuoted.push(true);
@ -1073,9 +1073,9 @@ export class SlashCommandParser {
listQuoted.push(false);
assignment = new SlashCommandUnnamedArgumentAssignment();
assignment.start = this.index;
if (!split && this.testQuotedValue()) {
if (!split && this.testEscapedQuotedValue()) {
// if where currently not splitting and the next bit is a quoted value, take the whole value
assignment.value = this.parseQuotedValue();
assignment.value = this.parseEscapedQuotedValue();
assignment.end = this.index;
listValues.push(assignment);
listQuoted.push(true);
@ -1093,9 +1093,9 @@ export class SlashCommandParser {
assignment.start = this.index;
if (split) this.discardWhitespace();
} else if (split) {
if (this.testQuotedValue()) {
if (this.testEscapedQuotedValue()) {
assignment.start = this.index;
assignment.value = this.parseQuotedValue();
assignment.value = this.parseEscapedQuotedValue();
assignment.end = this.index;
listValues.push(assignment);
listQuoted.push(true);
@ -1182,6 +1182,9 @@ export class SlashCommandParser {
testQuotedValue() {
return this.testSymbol('"');
}
testEscapedQuotedValue() {
return this.testSymbol('="');
}
testQuotedValueEnd() {
if (this.endOfText) {
if (this.verifyCommandNames) throw new SlashCommandParserError(`Unexpected end of quoted value at position ${this.index}`, this.text, this.index);
@ -1193,6 +1196,10 @@ export class SlashCommandParser {
}
return this.testSymbol('"') || (!this.flags[PARSER_FLAG.STRICT_ESCAPING] && this.testCommandEnd());
}
parseEscapedQuotedValue() {
this.take();
return this.parseQuotedValue();
}
parseQuotedValue() {
this.take(); // discard opening quote
let value = '';