Repository navigation
Accept escaped literal tabs in Yaml double-quoted scalars - #10283
Open
effect-bot wants to merge 27 commits into
Open
effect-bot wants to merge 27 commits into
effect-bot wants to merge 27 commits into
Conversation
Rebased onto v4/next-minor, which already returns Result from Yaml.parse (#10224). parseAll parses document streams with per-document anchors, accepts %YAML 1.2, and rejects other directives and plain scalars starting with '%'.
Start-marker lines read as mapping entries, anchor-only documents consuming the next marker, hashes inside quoted start-line content, and separation whitespace after '...' and directive parameters.
Block mappings and sequences end at column-0 document markers, an empty node does not consume a following marker, start-marker content is comment-stripped in its own lexical context, and trailing separation whitespace is allowed after '...' and directive parameters.
A byte order mark may start any document prefix, and only spaces and tabs separate a document end marker from a comment.
A BOM may start any document prefix, not only the input. Only spaces and tabs are separation after '...' and directive parameters.
Replace the document marker checks scattered through mapping, sequence, empty node, flow, plain, quoted and block scalar parsing with one per-document line bound computed when the document starts.
findIndex from the start of the input made a stream of many documents quadratic; a forward loop from the current line keeps it linear.
Tags, alias keys, explicit keys, nesting depth, and non-separation whitespace (NBSP, U+2028) that is currently trimmed as if it were YAML white space.
Reject tags and explicit keys instead of reading them as text, resolve scalar aliases used as mapping keys, bound collection nesting at 1000 levels, and treat only spaces and tabs as YAML white space.
Sequence-item mapping depth, alias keys resolving to '<<' in flow mappings, anchor and tag properties on keys, colons in alias names, and U+2028/U+2029 in anchored values.
Trim and fold white space with linear scans, count a sequence item's mapping before its first value, read anchors and tags on keys, keep colons in alias names, merge only through a plain '<<' key, and keep U+2028/U+2029 in anchored values.
Share one scalar-key resolver between block and flow mappings, read plain flow scalars and keys through one helper that rejects indicator prefixes, name the flow anchor-name boundary once, and add the flow-key quoting migration note to the changeset.
A sequence entry may start a nested sequence on its own line, quoted scalars inside flow collections may span lines, and a block sequence on a mapping key's line fails instead of being read as text.
Avoids quadratic growth from appending to and indexing one string, keeps an escaped trailing space before a quoted flow line break, and applies quoted-content indentation rules while a flow quote is open.
Reuse closingQuote and endsWithEscape to scan each line of a quoted flow scalar instead of a second hand-written quote scanner, and decide a sequence entry's shape once instead of testing it three times.
🦋 Changeset detectedLatest commit: 135336c The changes in this PR will be included in the next version bump. This PR includes changesets to release 33 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
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.
Summary
YAML 1.2.2 §5.7 (
ns-esc-horizontal-tab) lets a double-quoted scalar escape a tab as\tor as a backslash followed by a literal tab.Yaml.parseandYaml.parseAllonly accepted\t, so the literal-tab form failed with "Invalid YAML escape". This PR adds the missing entry to the escape table inparseDoubleQuoted. Line folding already keeps the decoded tab.The tests were added first in
d1652fc9d6, and this PR doesn't change them. They cover an escaped literal tab before a line break in a block value, nested under another key, and on the first line of a flow item.This PR builds on #10282 (and #10279, #10276 and #10271 beneath it), so it shows their commits until they merge. Only the last two commits are new here.
Validation
yaml2.9.1 and js-yaml 4.3.2. They cover root, mapping, sequence, flow item and key positions; the escape at the start, at the end, doubled or on a continuation line; and the escape next to escaped or plain spaces.pnpm lint-fixandpnpm jsdocs --checkpass.pnpm checkonly reports the existingapiStabilityLeakatcluster/ShardingRegistrationEvent.ts:67, which is also onv4/next-minor.Closes EFF-3232