diff --git a/src/scanscalar.cpp b/src/scanscalar.cpp index 0a47a46c8..be57b1cd5 100644 --- a/src/scanscalar.cpp +++ b/src/scanscalar.cpp @@ -204,7 +204,7 @@ std::string ScanScalar(Stream& INPUT, ScanScalarParams& params) { // post-processing if (params.trimTrailingSpaces) { - std::size_t pos = scalar.find_last_not_of(' '); + std::size_t pos = scalar.find_last_not_of(" \t"); if (lastEscapedChar != std::string::npos) { if (pos < lastEscapedChar || pos == std::string::npos) { pos = lastEscapedChar; diff --git a/test/integration/load_node_test.cpp b/test/integration/load_node_test.cpp index d0bbd4b7e..958e73512 100644 --- a/test/integration/load_node_test.cpp +++ b/test/integration/load_node_test.cpp @@ -284,6 +284,11 @@ TEST(NodeTest, SpecialFlow) { {"{:a}", NodeType::Map, 1, "{:a: ~}"}, {"{,}", NodeType::Map, 1, "{~: ~}"}, {"{a:,}", NodeType::Map, 1, "{a: ~}"}, + //testcase for the trailing TAB of scalar + {"key\t: value\t", NodeType::Map, 1, "key: value"}, + {"key\t: value\t #comment", NodeType::Map, 1, "key: value"}, + {"{key\t: value\t}", NodeType::Map, 1, "{key: value}"}, + {"{key\t: value\t #comment\n}", NodeType::Map, 1, "{key: value}"}, }; for (const SingleNodeTestCase& test : tests) { Node node = Load(test.input);