YamlDotNet icon indicating copy to clipboard operation
YamlDotNet copied to clipboard

Missing space between colon and value throws exception in case of flow mappings

Open fariadev22 opened this issue 7 years ago • 2 comments
trafficstars

#TestYaml
test:
  /{param}:
    type: {  collectionsTypes.mutableResource:{}}

The above YAML works fine in all other YAML parsers but not this one. I get the following exception: (Line: 4, Col: 14, Idx: 42) - (Line: 4, Col: 46, Idx: 74): While scanning a plain scalar, find unexpected ':'.

This exception does not come if there is space between colon and the curly bracket:

    type: {  collectionsTypes.mutableResource: {}}

However, as per YAML 1.1 specification this is a case of flow mappings (http://www.yaml.org/spec/current.html#id2544175) which uses separation spacing (http://www.yaml.org/spec/current.html#id2521201) i.e. this spacing is optional. It should be ignored during parsing and a missing space should not throw an exception since it is not invalid.

fariadev22 avatar Nov 23 '17 09:11 fariadev22

I'm sorry I was unable to answer this question in a timely fashion. As you have certainly moved on to other things, I will close this issue, but feel free to reopen it if necessary.

aaubry avatar Sep 25 '19 23:09 aaubry

Hey @aaubry . The issue still exists and yes, I'd like to reopen it. Thanks

fariadev22 avatar Sep 26 '19 04:09 fariadev22

This also fails in the reference parser. Therefore, I'm going with it's invalid YAML and that space is supposed to be there seeing as how it passes the reference parser when it's there.

http://ben-kiki.org/ypaste/data/66223/index.html

EdwardCooke avatar Jan 15 '23 04:01 EdwardCooke