fix lexing backslashes in single quoted strings
This commit is contained in:
parent
27127a4bab
commit
668732305a
@ -1170,7 +1170,9 @@ class Parser
|
|||||||
for (; \strlen($this->currentLine) > $cursor; ++$cursor) {
|
for (; \strlen($this->currentLine) > $cursor; ++$cursor) {
|
||||||
switch ($this->currentLine[$cursor]) {
|
switch ($this->currentLine[$cursor]) {
|
||||||
case '\\':
|
case '\\':
|
||||||
if (isset($this->currentLine[++$cursor])) {
|
if ("'" === $quotation) {
|
||||||
|
$value .= '\\';
|
||||||
|
} elseif (isset($this->currentLine[++$cursor])) {
|
||||||
$value .= '\\'.$this->currentLine[$cursor];
|
$value .= '\\'.$this->currentLine[$cursor];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1618,6 +1618,11 @@ YAML
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testBackslashInSingleQuotedString()
|
||||||
|
{
|
||||||
|
$this->assertSame(['foo' => 'bar\\'], $this->parser->parse("foo: 'bar\'"));
|
||||||
|
}
|
||||||
|
|
||||||
public function testParseMultiLineString()
|
public function testParseMultiLineString()
|
||||||
{
|
{
|
||||||
$this->assertEquals("foo bar\nbaz", $this->parser->parse("foo\nbar\n\nbaz"));
|
$this->assertEquals("foo bar\nbaz", $this->parser->parse("foo\nbar\n\nbaz"));
|
||||||
|
Reference in New Issue
Block a user