summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/common/VariantReader.cpp1
-rw-r--r--test/core/common/VariantReaderTest.cpp7
2 files changed, 8 insertions, 0 deletions
diff --git a/src/core/common/VariantReader.cpp b/src/core/common/VariantReader.cpp
index 600fd9b..db82954 100644
--- a/src/core/common/VariantReader.cpp
+++ b/src/core/common/VariantReader.cpp
@@ -563,6 +563,7 @@ std::pair<bool, Variant> VariantReader::parseGenericToken(
// Parse a string if a quote is reached
if (c == '"' || c == '\'') {
+ reader.resetPeek();
auto res = parseString(reader, logger);
return std::make_pair(res.first, res.second.c_str());
}
diff --git a/test/core/common/VariantReaderTest.cpp b/test/core/common/VariantReaderTest.cpp
index 9a9b694..cfdb1a0 100644
--- a/test/core/common/VariantReaderTest.cpp
+++ b/test/core/common/VariantReaderTest.cpp
@@ -610,6 +610,13 @@ TEST(VariantReader, parseGenericToken)
ASSERT_EQ("hello world", res.second.asString());
}
+ // String with whitespaces at the beginning.
+ {
+ CharReader reader(" \' test\'");
+ auto res = VariantReader::parseGenericToken(reader, logger, {';'}, true);
+ ASSERT_EQ(" test", res.second);
+ }
+
// Integer
{
CharReader reader("1234");