Repository navigation
fix(yaml): reject tab characters used as block indentation - #7366
Open
Harsh23Kashyap wants to merge 1 commit into
Open
Harsh23Kashyap wants to merge 1 commit into
Harsh23Kashyap wants to merge 1 commit into
Conversation
parse() accepted a tab at the start of a line as indentation. The tab was
skipped like any other whitespace, so the line was read at the wrong
depth: parse("a:\n\tb: 1") returned { a: null, b: 1 }.
Record when a tab appears before any content on a line and throw a
YamlSyntaxError if that line starts a block mapping entry or sequence
entry. Tabs used as separation (after a colon or a dash), in comments and
on blank lines are still accepted.
Closes denoland#7359
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7366 +/- ##
========================================
Coverage 95.04% 95.04%
========================================
Files 619 618 -1
Lines 52012 51773 -239
Branches 9450 9407 -43
========================================
- Hits 49434 49209 -225
+ Misses 2031 2022 -9
+ Partials 547 542 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #7359
parse()skips a tab at the start of a line like any other whitespace, so the line is read at the wrong depth.parse("a:\n\tb: 1")returns{ a: null, b: 1 }instead of throwing.This records when a tab shows up before any content on a line, and throws a
YamlSyntaxErrorif that line starts a block mapping or sequence entry. Tabs after a colon or dash, in comments, and on blank lines still parse as before.Before, on main:
After:
js-yaml and the
yamlnpm package reject the same three inputs. One correction to the issue:"- a\n-\tb"is accepted by both of them, because the tab there separates the dash from the value, so I left that case alone and added a test that it still parses.deno test yaml/ front_matter/passes, and the new test fails without the change.deno fmt,deno lintanddeno checkare clean foryaml/.