@@ -365,7 +365,7 @@ private static function parseSequence(string $sequence, int $flags, int &$i = 0,
365
365
}
366
366
}
367
367
368
- if (\is_string ($ value ) && '' !== $ value && '& ' === $ value [0 ] && Parser::preg_match (Parser::REFERENCE_PATTERN , $ value , $ matches )) {
368
+ if (! $ isQuoted && \is_string ($ value ) && '' !== $ value && '& ' === $ value [0 ] && Parser::preg_match (Parser::REFERENCE_PATTERN , $ value , $ matches )) {
369
369
$ references [$ matches ['ref ' ]] = $ matches ['value ' ];
370
370
$ value = $ matches ['value ' ];
371
371
}
@@ -497,6 +497,7 @@ private static function parseMapping(string $mapping, int $flags, int &$i = 0, a
497
497
}
498
498
break ;
499
499
default :
500
+ $ isValueQuoted = \in_array ($ mapping [$ i ], ['" ' , "' " ]);
500
501
$ value = self ::parseScalar ($ mapping , $ flags , [', ' , '} ' , "\n" ], $ i , null === $ tag , $ references );
501
502
// Spec: Keys MUST be unique; first one wins.
502
503
// Parser cannot abort this mapping earlier, since lines
@@ -505,7 +506,7 @@ private static function parseMapping(string $mapping, int $flags, int &$i = 0, a
505
506
if ('<< ' === $ key ) {
506
507
$ output += $ value ;
507
508
} elseif ($ allowOverwrite || !isset ($ output [$ key ])) {
508
- if (\is_string ($ value ) && '' !== $ value && '& ' === $ value [0 ] && Parser::preg_match (Parser::REFERENCE_PATTERN , $ value , $ matches )) {
509
+ if (! $ isValueQuoted && \is_string ($ value ) && '' !== $ value && '& ' === $ value [0 ] && Parser::preg_match (Parser::REFERENCE_PATTERN , $ value , $ matches )) {
509
510
$ references [$ matches ['ref ' ]] = $ matches ['value ' ];
510
511
$ value = $ matches ['value ' ];
511
512
}
0 commit comments