Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Syntax error in array [,] parsed as [null] #321

Closed
mayacoda opened this issue Jan 24, 2017 · 2 comments
Closed

Syntax error in array [,] parsed as [null] #321

mayacoda opened this issue Jan 24, 2017 · 2 comments
Labels

Comments

@mayacoda
Copy link

Hello,

I'm using js-yaml in a code editor that supports json and yaml user input and then transforms the content (if it is valid) into javascript objects for further manipulation.

I've encountered the following bug: If an array contains an extra comma ,, instead of throwing an exception for invalid yaml or json, the parser transforms the value into null. Although I include several other options, this is the simplest case in which the error occurs.

Code snippet:

var yaml = require('js-yaml');

var result = yaml.safeLoad('[,,]');

Expected:
YAMLException is thrown

Actual:

result === [null, null]
@puzrin puzrin added the bug label Jan 24, 2017
@puzrin
Copy link
Member

puzrin commented Jan 24, 2017

Seems to be a bug. libyaml-based parsers return error

@dervus ?

@rlidwka
Copy link
Member

rlidwka commented Dec 11, 2020

Fixed in adfee17 (currently in dev branch, gonna be released as js-yaml 4 later).

@rlidwka rlidwka closed this as completed Dec 11, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants