mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-08 12:21:17 +00:00
Properly allow a trailing tab character on a block scalar (#919)
Fixes #917
This commit is contained in:
@@ -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;
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user