From d65dbd64a12c43c12117c46521a29defb4239646 Mon Sep 17 00:00:00 2001 From: Vitaly Date: Wed, 8 May 2024 13:48:13 +0200 Subject: [PATCH] Fixed parsing of game configs that use quotes without spaces. Closes #374. --- src/corelib/ConfigEntryParser.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/corelib/ConfigEntryParser.cs b/src/corelib/ConfigEntryParser.cs index dd33695a..916e87f5 100644 --- a/src/corelib/ConfigEntryParser.cs +++ b/src/corelib/ConfigEntryParser.cs @@ -45,8 +45,15 @@ private static ConfigEntryParser InternalParse(string Value, bool TryParse) // Calculating the indices of the first space and the double slash character... int SpaceIndex = Value.IndexOf(" ", StringComparison.InvariantCulture); + int QuoteIndex = Value.IndexOf(@"""", StringComparison.InvariantCulture); int CommentIndex = Value.IndexOf("//", StringComparison.InvariantCulture); + // If the source string contains quotes we will use them instead of spaces... + if ((QuoteIndex > 0) && ((SpaceIndex == -1) || (QuoteIndex < SpaceIndex))) + { + return new ConfigEntryParser(Value.Substring(0, QuoteIndex), CommentIndex > QuoteIndex ? Value.Substring(QuoteIndex, CommentIndex - QuoteIndex) : Value.Remove(0, QuoteIndex), CommentIndex > 0 ? Value.Substring(CommentIndex + 2).Trim() : string.Empty); + } + // If the source string contains no spaces, return it as is... if ((SpaceIndex == -1) && (CommentIndex == -1)) {