Revert "Fix backward compatibility with escaped leading quote"

This reverts commit deb13e9c97.
This commit is contained in:
Cohee
2025-03-28 21:00:02 +02:00
parent deb13e9c97
commit bdcf9b088e

View File

@ -566,10 +566,9 @@ export class SlashCommandParser {
* Expects that the current char is taken after testing.
* @param {string|RegExp} sequence Sequence of chars or regex character group that is the symbol.
* @param {number} offset Offset from the current index (won't move the index if offset != 0).
* @param {boolean} escape Whether to escape the symbol with backslashes.
* @returns Whether the next characters are the indicated symbol.
*/
testSymbol(sequence, offset = 0, escape = true) {
testSymbol(sequence, offset = 0) {
if (!this.flags[PARSER_FLAG.STRICT_ESCAPING]) return this.testSymbolLooseyGoosey(sequence, offset);
// /echo abc | /echo def
// -> TOAST: abc
@ -588,7 +587,7 @@ export class SlashCommandParser {
// -> TOAST: *:}* {:
// -> TOAST: *{:* :}
const escapeOffset = this.jumpedEscapeSequence ? -1 : 0;
const escapes = escape ? this.text.slice(this.index + offset + escapeOffset).replace(/^(\\*).*$/s, '$1').length : 0;
const escapes = this.text.slice(this.index + offset + escapeOffset).replace(/^(\\*).*$/s, '$1').length;
const test = (sequence instanceof RegExp) ?
(text) => new RegExp(`^${sequence.source}`).test(text) :
(text) => text.startsWith(sequence)
@ -1046,9 +1045,6 @@ export class SlashCommandParser {
/**@type {SlashCommandUnnamedArgumentAssignment}*/
let assignment = new SlashCommandUnnamedArgumentAssignment();
assignment.start = this.index;
if (rawQuotes && this.testEscapedQuote()) {
this.take(); // discard the escaping backslash
}
if (!split && !rawQuotes && this.testQuotedValue()) {
// if the next bit is a quoted value, take the whole value and gather contents as a list
assignment.value = this.parseQuotedValue();
@ -1191,11 +1187,6 @@ export class SlashCommandParser {
testQuotedValue() {
return this.testSymbol('"');
}
testEscapedQuote() {
return this.testSymbol('\\"', 0, false);
}
testQuotedValueEnd() {
if (this.endOfText) {
if (this.verifyCommandNames) throw new SlashCommandParserError(`Unexpected end of quoted value at position ${this.index}`, this.text, this.index);