Skip to content

Commit

Permalink
Properly allow a trailing tab character on a block scalar (jbeder#919)
Browse files Browse the repository at this point in the history
  • Loading branch information
dota17 authored and Dan Dees committed Oct 16, 2020
1 parent 32e5a95 commit 475674a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/scanscalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions test/integration/load_node_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 475674a

Please sign in to comment.