Skip to content

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

Closed
@mayacoda

Description

@mayacoda

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @puzrin@rlidwka@mayacoda

        Issue actions

          Syntax error in array [,] parsed as [null] · Issue #321 · nodeca/js-yaml