Skip to content

Commit c3df6d8

Browse files
authored
Properly allow a trailing tab character on a block scalar (jbeder#919)
Fixes jbeder#917
1 parent 51ce663 commit c3df6d8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/scanscalar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ std::string ScanScalar(Stream& INPUT, ScanScalarParams& params) {
204204

205205
// post-processing
206206
if (params.trimTrailingSpaces) {
207-
std::size_t pos = scalar.find_last_not_of(' ');
207+
std::size_t pos = scalar.find_last_not_of(" \t");
208208
if (lastEscapedChar != std::string::npos) {
209209
if (pos < lastEscapedChar || pos == std::string::npos) {
210210
pos = lastEscapedChar;

test/integration/load_node_test.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,11 @@ TEST(NodeTest, SpecialFlow) {
284284
{"{:a}", NodeType::Map, 1, "{:a: ~}"},
285285
{"{,}", NodeType::Map, 1, "{~: ~}"},
286286
{"{a:,}", NodeType::Map, 1, "{a: ~}"},
287+
//testcase for the trailing TAB of scalar
288+
{"key\t: value\t", NodeType::Map, 1, "key: value"},
289+
{"key\t: value\t #comment", NodeType::Map, 1, "key: value"},
290+
{"{key\t: value\t}", NodeType::Map, 1, "{key: value}"},
291+
{"{key\t: value\t #comment\n}", NodeType::Map, 1, "{key: value}"},
287292
};
288293
for (const SingleNodeTestCase& test : tests) {
289294
Node node = Load(test.input);

0 commit comments

Comments
 (0)