diff --git a/src/lib/fy-parse.c b/src/lib/fy-parse.c index c485f1fd..e3149b3b 100644 --- a/src/lib/fy-parse.c +++ b/src/lib/fy-parse.c @@ -2839,6 +2839,12 @@ int fy_fetch_block_scalar(struct fy_parser *fyp, bool is_literal, int c) goto err_out; } + if (empty && c == '#' && fyp->column > fyp->indent && chomp != FYAC_KEEP) { + FYP_MARK_ERROR(fyp, &handle.start_mark, &handle.end_mark, FYEM_SCAN, + "empty block scalar with wrongly indented comment line after spaces only"); + goto err_out; + } + if (chomp_amt == (unsigned int)-1) chomp_amt = current_indent; diff --git a/test/emitter-examples/block5.yaml b/test/emitter-examples/block5.yaml deleted file mode 100644 index 3574e021..00000000 --- a/test/emitter-examples/block5.yaml +++ /dev/null @@ -1,5 +0,0 @@ -empty block scalar: > - - - - # comment diff --git a/test/emitter-examples/block8.yaml b/test/emitter-examples/block8.yaml deleted file mode 100644 index 97cdf5c8..00000000 --- a/test/emitter-examples/block8.yaml +++ /dev/null @@ -1,9 +0,0 @@ -test-comment: | - - - - # comment - - - - diff --git a/test/emitter-examples/block9.yaml b/test/emitter-examples/block9.yaml deleted file mode 100644 index 5959e60e..00000000 --- a/test/emitter-examples/block9.yaml +++ /dev/null @@ -1,9 +0,0 @@ -test-comment: |- - - - - # comment - - - -