From a44b4ca069749fa0e483953af625eebe040dcb4e Mon Sep 17 00:00:00 2001 From: Adeel Date: Thu, 28 May 2020 12:44:11 +0300 Subject: [PATCH] Fix indentation check for first content line --- YamlDotNet.Test/Serialization/SerializationTests.cs | 12 ++++++++++++ YamlDotNet/Core/Scanner.cs | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/YamlDotNet.Test/Serialization/SerializationTests.cs b/YamlDotNet.Test/Serialization/SerializationTests.cs index 823c841a4..f2277cacc 100644 --- a/YamlDotNet.Test/Serialization/SerializationTests.cs +++ b/YamlDotNet.Test/Serialization/SerializationTests.cs @@ -193,6 +193,18 @@ public void DeserializeCustomTags() .ShouldBeEquivalentTo(new { X = 10, Y = 20 }, o => o.ExcludingMissingMembers()); } + [Fact] + public void DeserializeWithGapsBetweenKeys() + { + var yamlReader = new StringReader(@"Text: > + Some Text. + +Value: foo"); + var result = Deserializer.Deserialize(yamlReader); + + result.Should().NotBeNull(); + } + [Fact] public void SerializeCustomTags() { diff --git a/YamlDotNet/Core/Scanner.cs b/YamlDotNet/Core/Scanner.cs index fa6a81a64..097d7f725 100644 --- a/YamlDotNet/Core/Scanner.cs +++ b/YamlDotNet/Core/Scanner.cs @@ -1693,7 +1693,7 @@ private int ScanBlockScalarBreaks(int currentIndent, StringBuilder breaks, bool throw new SemanticErrorException(end, cursor.Mark(), "While scanning a literal block scalar, found extra spaces in first line."); } - if (!isLiteral && maxIndent > cursor.LineOffset) + if (!isLiteral && maxIndent > cursor.LineOffset && indentOfFirstLine > -1) { // S98Z throw new SemanticErrorException(end, cursor.Mark(), "While scanning a literal block scalar, found more spaces in lines above first content line.");