@@ -171,7 +171,7 @@ public function parse($value, $flags = 0)
171
171
$ this ->refs [$ isRef ] = end ($ data );
172
172
}
173
173
} elseif (
174
- self ::preg_match ('#^(?P<key> ' .Inline::REGEX_QUOTED_STRING .'|(?:![^\s]+\s+)?[^ \'"\[\{!].*?) *\:(\s+(?P<value>.+? ))?\s* $#u ' , $ this ->currentLine , $ values )
174
+ self ::preg_match ('#^(?P<key> ' .Inline::REGEX_QUOTED_STRING .'|(?:![^\s]++ \s++ )?[^ \'"\[\{!].*?) *\:(\s++ (?P<value>.+))?$#u ' , $ this ->currentLine , $ values )
175
175
&& (false === strpos ($ values ['key ' ], ' # ' ) || in_array ($ values ['key ' ][0 ], array ('" ' , "' " )))
176
176
) {
177
177
if ($ context && 'sequence ' == $ context ) {
@@ -205,7 +205,7 @@ public function parse($value, $flags = 0)
205
205
$ mergeNode = true ;
206
206
$ allowOverwrite = true ;
207
207
if (isset ($ values ['value ' ]) && 0 === strpos ($ values ['value ' ], '* ' )) {
208
- $ refName = substr ($ values ['value ' ], 1 );
208
+ $ refName = substr (rtrim ( $ values ['value ' ]) , 1 );
209
209
if (!array_key_exists ($ refName , $ this ->refs )) {
210
210
throw new ParseException (sprintf ('Reference "%s" does not exist. ' , $ refName ), $ this ->getRealCurrentLineNb () + 1 , $ this ->currentLine );
211
211
}
@@ -246,15 +246,15 @@ public function parse($value, $flags = 0)
246
246
$ data += $ parsed ; // array union
247
247
}
248
248
}
249
- } elseif (isset ($ values ['value ' ]) && self ::preg_match ('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u ' , $ values ['value ' ], $ matches )) {
249
+ } elseif (isset ($ values ['value ' ]) && self ::preg_match ('#^&(?P<ref>[^ ]++ ) *+ (?P<value>.*)#u ' , $ values ['value ' ], $ matches )) {
250
250
$ isRef = $ matches ['ref ' ];
251
251
$ values ['value ' ] = $ matches ['value ' ];
252
252
}
253
253
254
254
$ subTag = null ;
255
255
if ($ mergeNode ) {
256
256
// Merge keys
257
- } elseif (!isset ($ values ['value ' ]) || '' == trim ( $ values ['value ' ], ' ' ) || 0 === strpos (ltrim ( $ values ['value ' ], ' ' ), ' # ' ) || (null !== $ subTag = $ this ->getLineTag (ltrim ( $ values ['value ' ], ' ' ) , $ flags ))) {
257
+ } elseif (!isset ($ values ['value ' ]) || '' === $ values ['value ' ] || 0 === strpos ($ values ['value ' ], '# ' ) || (null !== $ subTag = $ this ->getLineTag ($ values ['value ' ], $ flags ))) {
258
258
// hash
259
259
// if next line is less indented or equal, then it means that the current value is null
260
260
if (!$ this ->isNextLineIndented () && !$ this ->isNextLineUnIndentedCollection ()) {
@@ -286,7 +286,7 @@ public function parse($value, $flags = 0)
286
286
}
287
287
}
288
288
} else {
289
- $ value = $ this ->parseValue ($ values ['value ' ], $ flags , $ context );
289
+ $ value = $ this ->parseValue (rtrim ( $ values ['value ' ]) , $ flags , $ context );
290
290
// Spec: Keys MUST be unique; first one wins.
291
291
// But overwriting is allowed when a merge node is used in current block.
292
292
if ($ allowOverwrite || !isset ($ data [$ key ])) {
0 commit comments