Skip to content

Commit

Permalink
Merge pull request #129 from prozolic/pullreq
Browse files Browse the repository at this point in the history
Fix ConsumeBom
  • Loading branch information
hadashiA authored Oct 31, 2024
2 parents f8bbc04 + a4786ce commit 6020892
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions VYaml.Unity/Assets/VYaml/Runtime/Parser/Utf8YamlTokenizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ void ConsumeStreamEnd()
tokens.Enqueue(new Token(TokenType.StreamEnd));
}

void ConsumeBom()
bool ConsumeBom()
{
if (reader.IsNext(YamlCodes.Utf8Bom))
{
Expand All @@ -324,7 +324,11 @@ void ConsumeBom()
throw new YamlTokenizerException(CurrentMark, "BOM must be at the beginning of the stream or document.");
}
}
return true;
}

// not BOM.
return false;
}

void ConsumeDirective()
Expand Down Expand Up @@ -1482,7 +1486,7 @@ void SkipToNextToken()
}
break;
case 0xEF:
ConsumeBom();
if (!ConsumeBom()) return;
break;
default:
return;
Expand Down
8 changes: 6 additions & 2 deletions VYaml/Parser/Utf8YamlTokenizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ void ConsumeStreamEnd()
tokens.Enqueue(new Token(TokenType.StreamEnd));
}

void ConsumeBom()
bool ConsumeBom()
{
if (reader.IsNext(YamlCodes.Utf8Bom))
{
Expand All @@ -324,7 +324,11 @@ void ConsumeBom()
throw new YamlTokenizerException(CurrentMark, "BOM must be at the beginning of the stream or document.");
}
}
return true;
}

// not BOM.
return false;
}

void ConsumeDirective()
Expand Down Expand Up @@ -1482,7 +1486,7 @@ void SkipToNextToken()
}
break;
case 0xEF:
ConsumeBom();
if (!ConsumeBom()) return;
break;
default:
return;
Expand Down

0 comments on commit 6020892

Please sign in to comment.