EsotericSoftware / EsotericSoftware/yamlbeans

Commas seem optional in flow sequences - is this intended?

Open
#170 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
568
Forks
146
PR merge metrics
No merged PRs in 30d

Description

We noticed that:

```java
new YamlReader("['a'b]").read();
```

would parse without error, returning a list with 2 strings, `"a"` and `"b"`.

Other parsers (pyyaml, SnakeYAML) fail on parsing this, due to expecting a comma between entries.

This YAML specification [https://yaml.org/spec/1.2.2/#flow-sequences](https://yaml.org/spec/1.2.2/#flow-sequences) states:

> Flow sequence content is denoted by surrounding “[” and “]” characters.
> ...
> Sequence entries are separated by a “,” character.

I found it surpising that this library allowed it and thought it worth an issue for discussion.

Running a few more tests, it doesn't seem to always work - so I expect allowing the above is a subtle bug. e.g.

```java
System.err.println(new YamlReader("['a'b]").read());
System.err.println(new YamlReader("[a b c d]").read());
System.err.println(new YamlReader("['a,b' c d]").read());
System.err.println(new YamlReader("['a'b'c'd]").read());
```

outputs the following:

```
[a, b]
[a b c d]
[a,b, c d]
[a, b'c'd]
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.