File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -537,7 +537,10 @@ export class Lexer {
537537 if ( ! ch && ! this . atEnd ) return this . setNext ( 'block-scalar' )
538538 if ( indent >= this . indentNext ) {
539539 if ( this . blockScalarIndent === - 1 ) this . indentNext = indent
540- else this . indentNext += this . blockScalarIndent
540+ else {
541+ this . indentNext =
542+ this . blockScalarIndent + ( this . indentNext === 0 ? 1 : this . indentNext )
543+ }
541544 do {
542545 const cs = this . continueScalar ( nl + 1 )
543546 if ( cs === - 1 ) break
Original file line number Diff line number Diff line change @@ -412,6 +412,7 @@ describe('maps with no values', () => {
412412describe ( 'odd indentations' , ( ) => {
413413 test ( 'Block map with empty explicit key (#551)' , ( ) => {
414414 const doc = YAML . parseDocument < YAML . YAMLMap , false > ( '?\n? a' )
415+ expect ( doc . errors ) . toHaveLength ( 0 )
415416 expect ( doc . contents . items ) . toMatchObject ( [
416417 { key : { value : null } , value : null } ,
417418 { key : { value : 'a' } , value : null }
@@ -432,6 +433,12 @@ describe('odd indentations', () => {
432433 const doc = YAML . parseDocument < YAML . YAMLMap , false > ( 'a:\n{x}' )
433434 expect ( doc . errors ) . not . toHaveLength ( 0 )
434435 } )
436+
437+ test ( 'comment after top-level block scalar with indentation indicator (#547)' , ( ) => {
438+ const doc = YAML . parseDocument < YAML . Scalar , false > ( '|1\n x\n#c' )
439+ expect ( doc . errors ) . toHaveLength ( 0 )
440+ expect ( doc . contents ) . toMatchObject ( { value : 'x\n' } )
441+ } )
435442} )
436443
437444describe ( 'Excessive entity expansion attacks' , ( ) => {
You can’t perform that action at this time.
0 commit comments