fix lexing backslashes in single quoted strings

This commit is contained in:
Christian Flothmann 2020-12-01 15:29:09 +01:00
parent 27127a4bab
commit 668732305a
2 changed files with 8 additions and 1 deletions

View File

@ -1170,7 +1170,9 @@ class Parser
for (; \strlen($this->currentLine) > $cursor; ++$cursor) {
switch ($this->currentLine[$cursor]) {
case '\\':
if (isset($this->currentLine[++$cursor])) {
if ("'" === $quotation) {
$value .= '\\';
} elseif (isset($this->currentLine[++$cursor])) {
$value .= '\\'.$this->currentLine[$cursor];
}

View File

@ -1618,6 +1618,11 @@ YAML
];
}
public function testBackslashInSingleQuotedString()
{
$this->assertSame(['foo' => 'bar\\'], $this->parser->parse("foo: 'bar\'"));
}
public function testParseMultiLineString()
{
$this->assertEquals("foo bar\nbaz", $this->parser->parse("foo\nbar\n\nbaz"));