Skip to content

treat a carriage return as a line break when emitting - #1494

Open
soma0212 wants to merge 1 commit into
jbeder:masterfrom
soma0212:emitter-cr-line-break
Open

treat a carriage return as a line break when emitting#1494
soma0212 wants to merge 1 commit into
jbeder:masterfrom
soma0212:emitter-cr-line-break

Conversation

@soma0212

@soma0212 soma0212 commented Sep 9, 2026

Copy link
Copy Markdown

The scanner takes a bare CR as a line break (Exp::Break, after #986 and #1309), but the emitter helpers still only look for LF:

  • WriteComment re-prefixes # on LF only, so Comment("hi\rinjected: pwned") on a one-key map reparses as two keys, the comment tail landing as document structure
  • IsValidSingleQuotedScalar rejects LF but not CR, so 'a\rb' goes out raw and folds back to a b
  • IsValidLiteralScalar checks for neither, so a CR in a block scalar comes back as LF
  • WriteSingleQuotedString keeps its own bail-out in step with its validator

Plain scalars already fall back to double quotes for this (#607); the two remaining explicit formats now do the same, while the comment writer handles the break in place since it owns the # continuation. A CRLF pair collapses to one break instead of two.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant