@@ -389,7 +389,7 @@ private static function parseSequence(string $sequence, int $flags, int &$i = 0,
389
389
}
390
390
}
391
391
392
- if (\is_string ($ value ) && '' !== $ value && '& ' === $ value [0 ] && Parser::preg_match (Parser::REFERENCE_PATTERN , $ value , $ matches )) {
392
+ if (! $ isQuoted && \is_string ($ value ) && '' !== $ value && '& ' === $ value [0 ] && Parser::preg_match (Parser::REFERENCE_PATTERN , $ value , $ matches )) {
393
393
$ references [$ matches ['ref ' ]] = $ matches ['value ' ];
394
394
$ value = $ matches ['value ' ];
395
395
}
@@ -523,6 +523,7 @@ private static function parseMapping(string $mapping, int $flags, int &$i = 0, a
523
523
}
524
524
break ;
525
525
default :
526
+ $ isValueQuoted = \in_array ($ mapping [$ i ], ['" ' , "' " ]);
526
527
$ value = self ::parseScalar ($ mapping , $ flags , [', ' , '} ' , "\n" ], $ i , null === $ tag , $ references );
527
528
// Spec: Keys MUST be unique; first one wins.
528
529
// Parser cannot abort this mapping earlier, since lines
@@ -531,7 +532,7 @@ private static function parseMapping(string $mapping, int $flags, int &$i = 0, a
531
532
if ('<< ' === $ key ) {
532
533
$ output += $ value ;
533
534
} elseif ($ allowOverwrite || !isset ($ output [$ key ])) {
534
- if (\is_string ($ value ) && '' !== $ value && '& ' === $ value [0 ] && Parser::preg_match (Parser::REFERENCE_PATTERN , $ value , $ matches )) {
535
+ if (! $ isValueQuoted && \is_string ($ value ) && '' !== $ value && '& ' === $ value [0 ] && Parser::preg_match (Parser::REFERENCE_PATTERN , $ value , $ matches )) {
535
536
$ references [$ matches ['ref ' ]] = $ matches ['value ' ];
536
537
$ value = $ matches ['value ' ];
537
538
}
0 commit comments