YamlDotNet icon indicating copy to clipboard operation
YamlDotNet copied to clipboard

Double-quoted Multi-line string deserialization issue

Open jmcburn opened this issue 5 years ago • 4 comments
trafficstars

Seems there is a problem with deserializing double-quoted multi-line strings.

Until a few versions this deserialized fine and according to yaml testers this should not be a problem:

Problem:

Description: "Start: [c][FFFFFF]Wreckage Base[-][/c]        Equipment:[c][FFFFFF] Advanced[-][/c]        Tutorial:[c][FFFFFF] No[-][/c]


Lakes, swamps, deep forests, oceans and vast open plains are the geographical characteristics of this temperate planet. With a multitude of mountain ranges with snow-capped peaks, some formed by volcanic activity, others by glacial flow, the climate is moderate and the atmosphere is breathable.
 
  
Recommended for experienced players who do not need the basic tutorial and want to start in a base with advanced equipment."

Now I get the following error:

"While scanning a multi-line double-quoted scalar, found wrong indentation."

When I add indentations to the lines, it works fine:

Description: "Start: [c][FFFFFF]Wreckage Base[-][/c]        Equipment:[c][FFFFFF] Advanced[-][/c]        Tutorial:[c][FFFFFF] No[-][/c]


  Lakes, swamps, deep forests, oceans and vast open plains are the geographical characteristics of this temperate planet. With a multitude of mountain ranges with snow-capped peaks, some formed by volcanic activity, others by glacial flow, the climate is moderate and the atmosphere is breathable.
 
  
  Recommended for experienced players who do not need the basic tutorial and want to start in a base with advanced equipment."

In my experience and as far as my researches went, indentations on follow-up lines of double-quoted multi-line strings are are not necessary.

jmcburn avatar Jun 26 '20 15:06 jmcburn

I'm experiencing the same issue with the latest version. I agree with @jmcburn, according to the 1.2 specification (Example 7.5), double quoted strings are allowed to have line breaks that carry into the expressed content.

markjulmar avatar Jul 06 '20 15:07 markjulmar

I can third this.

BigBallard avatar Jan 20 '21 17:01 BigBallard

This has been discussed in #557. It turns out that multiline double-quoted scalars must be indented. Attempting to parse this example in the reference parser gives an error as well. The previous behaviour was incorrect and has been fixed so that the parser is more compliant with the specification.

aaubry avatar Jan 20 '21 18:01 aaubry

@aaubry I see, but is there a way to make YamlDotNet still being able to read them once and then on writing the yaml again, make it emit those quoted strings in the correct way with indentation?

The problem is that I now have a few hundred, if not thousands of unreadable yamls now, and fixing them by hand might take quite some time.

Any help would be appreciated.

jmcburn avatar Jan 20 '21 19:01 jmcburn