Skip to content

Commit

Permalink
Fix indentation check for first content line
Browse files Browse the repository at this point in the history
  • Loading branch information
am11 committed May 28, 2020
1 parent 97ffd41 commit a44b4ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions YamlDotNet.Test/Serialization/SerializationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
2 changes: 1 addition & 1 deletion YamlDotNet/Core/Scanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down

0 comments on commit a44b4ca

Please sign in to comment.