Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scanner - ignore trailing tabs #711

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix scanner to ignore trailing tabs
  • Loading branch information
Eric Ihli authored and eihli committed Aug 29, 2023
commit d4a7da83e425811fa085f7eca13988fd6f95ad07
10 changes: 10 additions & 0 deletions lib/yaml/scanner.py
Original file line number Diff line number Diff line change
@@ -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
@@ -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()
1 change: 1 addition & 0 deletions tests/data/trailing-tab.code
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"foo": ["bar"]}
2 changes: 2 additions & 0 deletions tests/data/trailing-tab.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
foo:
- bar