Skip to content

Commit

Permalink
Forbid lines starting with tabs in block mode
Browse files Browse the repository at this point in the history
  • Loading branch information
perlpunk committed Dec 25, 2021
1 parent 158afb6 commit 9081f88
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/YAML/PP/Lexer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ sub fetch_next_tokens {
if (not $spaces and $$yaml =~ s/\A(---|\.\.\.)(?=$RE_WS|\z)//) {
$self->push_tokens([ $TOKEN_NAMES{ $1 } => $1, $self->line ]);
}
elsif ($$yaml =~ m/\A[ \t]+(#.*)?\z/) {
elsif ($self->flowcontext and $$yaml =~ m/\A[ \t]+(#.*)?\z/) {
$self->push_tokens([ EOL => join('', @$next_line), $self->line ]);
$self->set_next_line(undef);
return $next;
Expand Down Expand Up @@ -559,6 +559,9 @@ sub fetch_block {
}
if ((length $spaces) < $current_indent) {
if (length $content) {
if ($content =~ m/\A\t/) {
$self->exception("Invalid block scalar");
}
last;
}
else {
Expand Down
1 change: 1 addition & 0 deletions t/invalid/i036/===
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Tabs in various contexts
3 changes: 3 additions & 0 deletions t/invalid/i036/in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
foo: |
bar: 1
4 changes: 4 additions & 0 deletions t/invalid/i036/test.event
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
+STR
+DOC
+MAP
=VAL :foo

0 comments on commit 9081f88

Please sign in to comment.