Skip to content

Commit

Permalink
Updated InternalParse() method to remove spaces in parsed strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
xvitaly committed May 8, 2024
1 parent d65dbd6 commit badd0b3
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/corelib/ConfigEntryParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private static ConfigEntryParser InternalParse(string Value, bool TryParse)
// 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);
return new ConfigEntryParser(Value.Substring(0, QuoteIndex).Trim(), (CommentIndex > QuoteIndex ? Value.Substring(QuoteIndex, CommentIndex - QuoteIndex) : Value.Remove(0, QuoteIndex)).Trim(), CommentIndex > 0 ? Value.Substring(CommentIndex + 2).Trim() : string.Empty);
}

// If the source string contains no spaces, return it as is...
Expand All @@ -63,10 +63,7 @@ private static ConfigEntryParser InternalParse(string Value, bool TryParse)
// Parsing the source string...
try
{
string NameStr = Value.Substring(0, SpaceIndex);
string ValueStr = CommentIndex > SpaceIndex ? Value.Substring(SpaceIndex + 1, CommentIndex - SpaceIndex - 1) : Value.Remove(0, SpaceIndex + 1);
string CommentStr = CommentIndex > 0 ? Value.Substring(CommentIndex + 2).Trim() : string.Empty;
return new ConfigEntryParser(NameStr, ValueStr, CommentStr);
return new ConfigEntryParser(Value.Substring(0, SpaceIndex).Trim(), (CommentIndex > SpaceIndex ? Value.Substring(SpaceIndex + 1, CommentIndex - SpaceIndex - 1) : Value.Remove(0, SpaceIndex + 1)).Trim(), CommentIndex > 0 ? Value.Substring(CommentIndex + 2).Trim() : string.Empty);
}
catch
{
Expand Down

0 comments on commit badd0b3

Please sign in to comment.