flyx / NimYAML

YAML implementation for Nim
https://nimyaml.org
Other
191 stars 36 forks source link

`| >` wrapping functionality can generate invalid YAML #113

Closed quantimnot closed 2 years ago

quantimnot commented 2 years ago

I think I have found an edge case :)

import yaml

# works:
echo dump """
rr
rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rr
"""

# doesn't work:
echo dump """
r
rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr r
"""
var r: string
load dump """
r
rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr r
""", r
%YAML 1.2
%TAG !n! tag:nimyaml.org,2016:
--- 
!!str >
  rr

  rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
  rr
%YAML 1.2
%TAG !n! tag:nimyaml.org,2016:
--- 
!!str > r

  rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr r
[NimYAML] Error in file serialization.nim at line 1355:
Unexpected exception: LexerError
… stacktrace [YamlStreamError: Illegal character after block scalar header: "r"]
stream.nim(106)          next
serialization.nim(1327)  construct

… stacktrace [LexerError: Illegal character after block scalar header: "r"]
lex.nim(476)             readBlockScalar

[NimYAML] Please report this bug.
quantimnot commented 2 years ago

It is already fixed in some newer commits than what I had. My bad