Fix bug where escape sequences in string arrays are not parsed correctly

This commit is contained in:
2025-02-02 21:47:21 +01:00
parent e3c3b76caa
commit 2880cfd2f3
3 changed files with 13 additions and 2 deletions

View File

@@ -547,7 +547,16 @@ minipp::EResult minipp::MiniPPFile::Values::ArrayValue::Parse(const std::string&
if (isInString) if (isInString)
{ {
if (c == '\\') if (c == '\\')
{
if (i + 1 >= str.size())
{
PP_COUT("Syntax error: Bad escape sequence: '\\' at end of string");
return EResult::FormatError;
}
currentElement += c;
currentElement += str[i + 1];
++i; ++i;
}
else if (c == '"') else if (c == '"')
{ {
isInString = false; isInString = false;

View File

@@ -1,10 +1,11 @@
[game] [game]
name = "Test Game" name = "Test Game\nNext Line"
version = "1.0.0" version = "1.0.0"
year = 2025 year = 2025
completionPercentage = 50.0f completionPercentage = 50.0f
# Should only be true if completionPercentage is 100 # Should only be true if completionPercentage is 100
is_completed = false is_completed = false
testargs = ["this is a \"test\"", "this is\n the next line"]
# This section is about # This section is about
# the settings of a game window # the settings of a game window

View File

@@ -1,7 +1,8 @@
[game] [game]
name = "Test Game" name = "Test Game\nNext Line"
completionPercentage = 50.000000 completionPercentage = 50.000000
version = "1.0.0" version = "1.0.0"
testargs = ["this is a \"test\"", "this is\n the next line"]
year = 2025 year = 2025
# Should only be true if completionPercentage is 100 # Should only be true if completionPercentage is 100
is_completed = false is_completed = false