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

Mapping key syntax error parsed as if there is no issue #418

Closed
shockey opened this issue Apr 19, 2018 · 6 comments
Closed

Mapping key syntax error parsed as if there is no issue #418

shockey opened this issue Apr 19, 2018 · 6 comments
Labels

Comments

@shockey
Copy link
Contributor

shockey commented Apr 19, 2018

js-yaml appears to be treating badly-formed mapping keys as if they're well-formed.

This was originally raised as a Swagger-Editor issue (swagger-api/swagger-editor#1740).

Example

var jsYaml = require("js-yaml")

const str = `
myObj:
  a: "something"
  b: "some other thing" c: "third thing"
`

jsYaml.safeLoad(str)

Expected result

An error, maybe something along the lines of bad indentation of a mapping entry at line 4, column 24?

Actual result

{  
  myObj:{  
    a:'something',
    b:'some other thing',
    c:'third thing'
  }
}
@webron
Copy link

webron commented Jul 30, 2018

@puzrin - while this is not a critical issue, it does pose challenges to our users from time to time. Any idea if you'll have to look into it? We'd look into submitting a fix ourselves too, just don't want to duplicate the efforts.

@puzrin
Copy link
Member

puzrin commented Jul 30, 2018

I'd prefer to wait for PR. But prior to do something, there should be clear understanding what spec says about such thing. Probably, the most easy way is to check libyaml-based parsers.

@ingydotnet
Copy link

libyaml reports:

      did not find expected key

  was found at document: 1, line: 3, column: 25
  while parsing a block mapping at line: 2, column: 3

@puzrin
Copy link
Member

puzrin commented Jul 31, 2018

@ingydotnet thanks!

@ingydotnet
Copy link

rlidwka added a commit that referenced this issue Dec 29, 2020
@rlidwka
Copy link
Member

rlidwka commented Dec 29, 2020

Fixed in f0f205b (currently in dev branch).

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

No branches or pull requests

5 participants