diff --git a/lib/yaml/scanner.py b/lib/yaml/scanner.py index de925b07..35621ea5 100644 --- a/lib/yaml/scanner.py +++ b/lib/yaml/scanner.py @@ -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() diff --git a/tests/data/trailing-tab.code b/tests/data/trailing-tab.code new file mode 100644 index 00000000..44bcba58 --- /dev/null +++ b/tests/data/trailing-tab.code @@ -0,0 +1 @@ +{"foo": ["bar"]} diff --git a/tests/data/trailing-tab.data b/tests/data/trailing-tab.data new file mode 100644 index 00000000..6337bc97 --- /dev/null +++ b/tests/data/trailing-tab.data @@ -0,0 +1,2 @@ +foo: + - bar