@@ -45,13 +45,13 @@ function Read-YamlStreamCore {
4545 - MaxAliases $MaxAliases - MaxScalarLength $MaxScalarLength `
4646 - MaxTagLength $MaxTagLength - MaxTotalTagLength $MaxTotalTagLength `
4747 - MaxNumericLength $MaxNumericLength
48- $text = $context.Text
4948 $lines = $context.Lines
5049 $lineStarts = $context.LineStarts
5150 $documents = [System.Collections.Generic.List [object ]]::new()
5251 $implicitDocumentSeen = $false
5352
5453 while ($context.LineIndex -lt $lines.Count ) {
54+ Read-YamlDocumentByteOrderMark - Context $context
5555 Skip-YamlBlockTrivia - Context $context
5656 if ($context.LineIndex -ge $lines.Count ) {
5757 break
@@ -76,7 +76,8 @@ function Read-YamlStreamCore {
7676
7777 if ($context.LineIndex -ge $lines.Count ) {
7878 if ($directiveSeen ) {
79- $mark = New-YamlMark - Index $text.Length - Line ([Math ]::Max(0 , $lines.Count - 1 )) - Column 0
79+ $mark = New-YamlMark - Index $context.Text.Length `
80+ - Line ([Math ]::Max(0 , $lines.Count - 1 )) - Column 0
8081 throw (New-YamlException - Start $mark - End $mark - ErrorId ' YamlDirectiveWithoutDocument' - Message (
8182 ' YAML directives must be followed by an explicit document start marker.'
8283 ))
@@ -113,7 +114,8 @@ function Read-YamlStreamCore {
113114 $context.LineIndex ++
114115 Skip-YamlBlockTrivia - Context $context
115116 if ($context.LineIndex -ge $lines.Count -or
116- $lines [$context.LineIndex ] -match ' ^(?:---|\.\.\.)(?:[ \t]|$)' ) {
117+ $lines [$context.LineIndex ] -match ' ^(?:---|\.\.\.)(?:[ \t]|$)' -or
118+ (Test-YamlDocumentByteOrderMark - Context $context - RequireDocumentStart)) {
117119 $mark = New-YamlMark - Index ($lineStarts [$markerLine ] + 3 ) - Line $markerLine - Column 3
118120 $document = New-YamlEmptyScalar - Context $context - Depth 1 - Mark $mark
119121 } else {
@@ -162,6 +164,8 @@ function Read-YamlStreamCore {
162164 }
163165 $documents.Add ($document )
164166
167+ Skip-YamlBlockTrivia - Context $context
168+ Read-YamlDocumentByteOrderMark - Context $context - RequireDocumentStart
165169 Skip-YamlBlockTrivia - Context $context
166170 $explicitEnd = $false
167171 if ($context.LineIndex -lt $lines.Count -and
0 commit comments