Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions VYaml.Tests/Parser/Utf8YamlTokenizerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,35 @@ public void CodePointUtf32Test(string literal)
Assert.That(Scalar(ref tokenizer).ToString(), Is.EqualTo(literal));
}

[Test]
[Timeout(5000)]
public void MappingKeyWithColonAtEof()
{
CreateTokenizer(" property:", out var tokenizer);

Assert.That(tokenizer.Read(), Is.True);
Assert.That(tokenizer.CurrentTokenType, Is.EqualTo(TokenType.StreamStart));

Assert.That(tokenizer.Read(), Is.True);
Assert.That(tokenizer.CurrentTokenType, Is.EqualTo(TokenType.BlockMappingStart));

Assert.That(tokenizer.Read(), Is.True);
Assert.That(tokenizer.CurrentTokenType, Is.EqualTo(TokenType.KeyStart));

Assert.That(tokenizer.Read(), Is.True);
Assert.That(tokenizer.CurrentTokenType, Is.EqualTo(TokenType.PlainScalar));
Assert.That(Scalar(ref tokenizer).ToString(), Is.EqualTo("property"));

Assert.That(tokenizer.Read(), Is.True);
Assert.That(tokenizer.CurrentTokenType, Is.EqualTo(TokenType.ValueStart));

Assert.That(tokenizer.Read(), Is.True);
Assert.That(tokenizer.CurrentTokenType, Is.EqualTo(TokenType.BlockEnd));

Assert.That(tokenizer.Read(), Is.True);
Assert.That(tokenizer.CurrentTokenType, Is.EqualTo(TokenType.StreamEnd));
}

static void CreateTokenizer(IEnumerable<string> lines, out Utf8YamlTokenizer tokenizer)
{
var yaml = string.Join("\n", lines);
Expand Down
3 changes: 2 additions & 1 deletion VYaml/Parser/Utf8YamlTokenizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ void ConsumeNextToken()
ConsumeComplexKeyStart();
break;
case YamlCodes.MapValueIndent
when (TryPeek(1, out var nextCode) && YamlCodes.IsEmpty(nextCode)) ||
when !TryPeek(1, out var nextCode) ||
YamlCodes.IsEmpty(nextCode) ||
(flowLevel > 0 && (YamlCodes.IsAnyFlowSymbol(nextCode) || mark.Position == adjacentValueAllowedAt)):
ConsumeValueStart();
break;
Expand Down
Loading