Skip to content

false-positive in YAML stream detection #673

@yugui

Description

@yugui

It seems like that go-jsonnet detects a false-positive YAML stream when std.parseYaml parses a YAML document that contains --- in data. It is also an inconsistent behavior with the C++ version.

How to reproduce

Suppose that we have the next test.jsonnet:

std.parseYaml('foo---: bar')

This is not a YAML stream, and it is not far from the example shown in the std library reference. So I expect this input produces the next result:

{
   "foo---": "bar"
}

The C++ implementation actually produces this expected result. However, go-jsonnet produces the next output.

$ jsonnet -v
Jsonnet commandline interpreter (Go implementation) v0.19.1
$ jsonnet test.jsonnet
[
   {
      "foo---": "bar"
   }
]

I believe this is because builtinParseYAML (builtins.go#L1375) detects YAML streams too loosely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions