From b19b2fbb38ea109547bcae1b7e82d0b9bd6c1abc Mon Sep 17 00:00:00 2001 From: Ske Date: Sun, 27 Oct 2019 17:09:15 +0100 Subject: [PATCH] Fix matching multiple consecutive quoted strings --- PluralKit.Bot/CommandSystem/Parameters.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/PluralKit.Bot/CommandSystem/Parameters.cs b/PluralKit.Bot/CommandSystem/Parameters.cs index b1fb9447..eccafa46 100644 --- a/PluralKit.Bot/CommandSystem/Parameters.cs +++ b/PluralKit.Bot/CommandSystem/Parameters.cs @@ -38,10 +38,12 @@ namespace PluralKit.Bot.CommandSystem return _cmd.Substring(start, end - start).Trim(); } - public string Remainder() => _cmd.Substring(_ptr).Trim(); + public string Remainder() => _cmd.Substring(Math.Min(_ptr, _cmd.Length)).Trim(); public string FullCommand => _cmd; // Returns tuple of (startpos, endpos, advanceafter) + // advanceafter is how much to move the pointer afterwards to point it + // at the start of the next word private ValueTuple? NextWordPosition() { // Is this the end of the string? @@ -65,7 +67,7 @@ namespace PluralKit.Bot.CommandSystem return (_ptr, _cmd.Length, 0); } - return (_ptr + 1, endQuotePosition, 1); + return (_ptr + 1, endQuotePosition, 2); } }