Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows command arguments to consist of only 'escaped' characters #994

Merged
merged 2 commits into from
Jun 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions src/Discord.Net.Commands/CommandParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,7 @@ public static async Task<ParseResult> ParseArgsAsync(CommandInfo command, IComma
else
c = '\0';

//If this character is escaped, skip it
if (isEscaping)
{
if (curPos != endPos)
{
argBuilder.Append(c);
isEscaping = false;
continue;
}
}
//Are we escaping the next character?
if (c == '\\' && (curParam == null || !curParam.IsRemainder))
{
isEscaping = true;
continue;
}

//If we're processing an remainder parameter, ignore all other logic
//If we're processing a remainder parameter, ignore all other logic
if (curParam != null && curParam.IsRemainder && curPos != endPos)
{
argBuilder.Append(c);
Expand Down Expand Up @@ -83,6 +66,23 @@ public static async Task<ParseResult> ParseArgsAsync(CommandInfo command, IComma
}
}

//If this character is escaped, skip it
if (isEscaping)
{
if (curPos != endPos)
{
argBuilder.Append(c);
isEscaping = false;
continue;
}
}
//Are we escaping the next character?
if (c == '\\' && (curParam == null || !curParam.IsRemainder))
{
isEscaping = true;
continue;
}

//Has this parameter ended yet?
string argString = null;
if (curPart == ParserPart.Parameter)
Expand Down