@@ -96,7 +96,6 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport =
9696 $ data [] = $ parser ->parse ($ this ->getNextEmbedBlock (null , true ), $ exceptionOnInvalidType , $ objectSupport );
9797 } else {
9898 if (isset ($ values ['leadspaces ' ])
99- && ' ' == $ values ['leadspaces ' ]
10099 && preg_match ('#^(?P<key> ' .Inline::REGEX_QUOTED_STRING .'|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+?))?\s*$#u ' , $ values ['value ' ], $ matches )
101100 ) {
102101 // this is a compact notation element, add to next block and parse
@@ -106,7 +105,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport =
106105
107106 $ block = $ values ['value ' ];
108107 if ($ this ->isNextLineIndented ()) {
109- $ block .= "\n" .$ this ->getNextEmbedBlock ($ this ->getCurrentLineIndentation () + 2 );
108+ $ block .= "\n" .$ this ->getNextEmbedBlock ($ this ->getCurrentLineIndentation () + strlen ( $ values [ ' leadspaces ' ]) + 1 );
110109 }
111110
112111 $ data [] = $ parser ->parse ($ block , $ exceptionOnInvalidType , $ objectSupport );
@@ -313,7 +312,14 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false)
313312 $ newIndent = $ indentation ;
314313 }
315314
316- $ data = array (substr ($ this ->currentLine , $ newIndent ));
315+ $ data = array ();
316+ if ($ this ->getCurrentLineIndentation () >= $ newIndent ) {
317+ $ data [] = substr ($ this ->currentLine , $ newIndent );
318+ } else {
319+ $ this ->moveToPreviousLine ();
320+
321+ return ;
322+ }
317323
318324 if ($ inSequence && $ oldLineIndentation === $ newIndent && '- ' === $ data [0 ][0 ]) {
319325 // the previous line contained a dash but no item content, this line is a sequence item with the same indentation
@@ -336,7 +342,7 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false)
336342 $ removeComments = !preg_match ($ removeCommentsPattern , $ this ->currentLine );
337343 }
338344
339- if ($ isItUnindentedCollection && !$ this ->isStringUnIndentedCollectionItem ($ this ->currentLine )) {
345+ if ($ isItUnindentedCollection && !$ this ->isStringUnIndentedCollectionItem ($ this ->currentLine ) && $ newIndent === $ indent ) {
340346 $ this ->moveToPreviousLine ();
341347 break ;
342348 }
0 commit comments