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