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

Incorrect dump of block scalar with leading newlines and spaces #403

Closed
trevorr opened this issue Mar 15, 2018 · 1 comment
Closed

Incorrect dump of block scalar with leading newlines and spaces #403

trevorr opened this issue Mar 15, 2018 · 1 comment

Comments

@trevorr
Copy link
Contributor

trevorr commented Mar 15, 2018

The following code dumps invalid YAML:

console.log(yaml.safeDump({ str: '\n    a\nb' }))

Invalid output due to indentation:

str: |-

      a
  b

Leading spaces are handled in general by an indentation indicator (below), but leading newlines seem to thwart this (above):

console.log(yaml.safeDump({ str: '    a\nb' }))

Valid output:

str: |2-
      a
  b

The results above are from version 3.11.0.

@aepsilon
Copy link
Contributor

Good catch. Thanks for putting in a fix too; it looks clean.

puzrin pushed a commit that referenced this issue Mar 16, 2018
…cator is needed (#404)

* Check for leading newlines when determining if block indentation indicator is needed

Fixes #403

* Perf: Swap order of checks for block indentation edge case
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

No branches or pull requests

2 participants