Skip to content

Commit b6aca12

Browse files
committed
Fix parsing of invalid YAML: same-line block container starts
1 parent cab894f commit b6aca12

3 files changed

Lines changed: 382 additions & 155 deletions

File tree

changelog/current.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## General fixes and improvements
22

3+
This release focuses in compliance with the YAML standard, mostly by ensuring parse errors in invalid YAML cases.
4+
35
- Narrow the scope of `%TAG` to only the following document, as per the standard ([PR#588](https://github.com/biojppm/rapidyaml/pull/588)). This required or prompted some API changes:
46
- Added new type `TagDirectives`
57
- Added `ParseOptions::resolve_tags()` and `ParseOptions::resolve_tags_all()` options to enforce resolution of tags while parsing. When disabled (which is the default), the tree still has `Tree::resolve_tags()` to perform post-parsing or programmatic resolution.
@@ -16,7 +18,6 @@
1618
## YAML fixes: valid cases
1719

1820
Fix parsing of **valid** YAML corner cases:
19-
- Ensure tags/anchors are not omitted. This was happening in some flow maps ([PR#587](https://github.com/biojppm/rapidyaml/pull/587)).
2021
- Ambiguity of tags/anchors in ? mode ([PR#587](https://github.com/biojppm/rapidyaml/pull/587)):
2122
```yaml
2223
? &mapanchor
@@ -55,6 +56,7 @@ Fix parsing of **valid** YAML corner cases:
5556
? ? - c # nested explicit keys were also fixed
5657
? - d
5758
```
59+
- Missing tags/anchors in some flow maps ([PR#587](https://github.com/biojppm/rapidyaml/pull/587)).
5860

5961

6062
## YAML fixes: invalid cases
@@ -165,9 +167,9 @@ Ensure parse errors for **invalid** YAML cases, and improve reported error locat
165167
```
166168
- directives with extra tokens ([PR#587](https://github.com/biojppm/rapidyaml/pull/587)):
167169
```yaml
168-
%YAML 1.2 this is wrong
169-
%YAML 1.2 # this is ok
170-
%TAG ! my- ! this is also wrong
170+
%YAML 1.2 blabla # invalid
171+
%YAML 1. # this is ok
172+
%TAG ! my- ! blabla # this is also wrong
171173
---
172174
```
173175
- multiline implicit keys are invalid ([PR#587](https://github.com/biojppm/rapidyaml/pull/587)):
@@ -182,5 +184,27 @@ Ensure parse errors for **invalid** YAML cases, and improve reported error locat
182184
seq]: invalid
183185
{multiline:
184186
map}: invalid
185-
```
186-
187+
```
188+
- invalid block containers after document open ([PR#592](https://github.com/biojppm/rapidyaml/pull/592)):
189+
```yaml
190+
--- a: b # invalid
191+
--- - a # invalid
192+
--- ? a # invalid
193+
```
194+
- invalid block containers after in-block open ([PR#592](https://github.com/biojppm/rapidyaml/pull/592)):
195+
```yaml
196+
a: - b # invalid
197+
a: ? b # invalid
198+
```
199+
- same-line repeated annotations ([PR#592](https://github.com/biojppm/rapidyaml/pull/592)):
200+
```yaml
201+
!a
202+
!b foo: bar # ok
203+
---
204+
&a
205+
&b foo: bar # ok
206+
---
207+
!a !b foo: bar # invalid
208+
---
209+
&a &b foo: bar # invalid
210+
```

0 commit comments

Comments
 (0)