Skip to content

Commit

Permalink
Fix scanner to ignore trailing tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Ihli committed Apr 25, 2023
1 parent 957ae4d commit c87a062
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/yaml/scanner.py
Expand Up @@ -749,6 +749,14 @@ def check_plain(self):

# Scanners.

def scan_past_tabs_to_newline(self):
i = 0
while self.peek(i) in ' \t':
i += 1
if self.peek(i) in '\0\r\n\x86\u2028\u2029':
self.forward(i)


def scan_to_next_token(self):
# We ignore spaces, line breaks and comments.
# If we find a line break in the block context, we set the flag
Expand All @@ -775,6 +783,8 @@ def scan_to_next_token(self):
while not found:
while self.peek() == ' ':
self.forward()
if self.peek() == '\t':
self.scan_past_tabs_to_newline()
if self.peek() == '#':
while self.peek() not in '\0\r\n\x85\u2028\u2029':
self.forward()
Expand Down
1 change: 1 addition & 0 deletions tests/data/trailing-tab.code
@@ -0,0 +1 @@
{"foo": ["bar"]}
2 changes: 2 additions & 0 deletions tests/data/trailing-tab.data
@@ -0,0 +1,2 @@
foo:
- bar

0 comments on commit c87a062

Please sign in to comment.