[ExpressionLanguage] Fixed an issue with # characters in double quoted string literals
This commit is contained in:
parent
dfabc4a61a
commit
0c2622e2e7
@ -69,7 +69,7 @@ class Lexer
|
|||||||
|
|
||||||
$tokens[] = new Token(Token::PUNCTUATION_TYPE, $expression[$cursor], $cursor + 1);
|
$tokens[] = new Token(Token::PUNCTUATION_TYPE, $expression[$cursor], $cursor + 1);
|
||||||
++$cursor;
|
++$cursor;
|
||||||
} elseif (preg_match('/"([^#"\\\\]*(?:\\\\.[^#"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As', $expression, $match, null, $cursor)) {
|
} elseif (preg_match('/"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As', $expression, $match, null, $cursor)) {
|
||||||
// strings
|
// strings
|
||||||
$tokens[] = new Token(Token::STRING_TYPE, stripcslashes(substr($match[0], 1, -1)), $cursor + 1);
|
$tokens[] = new Token(Token::STRING_TYPE, stripcslashes(substr($match[0], 1, -1)), $cursor + 1);
|
||||||
$cursor += strlen($match[0]);
|
$cursor += strlen($match[0]);
|
||||||
|
@ -78,6 +78,14 @@ class LexerTest extends \PHPUnit_Framework_TestCase
|
|||||||
array(new Token('operator', '..', 1)),
|
array(new Token('operator', '..', 1)),
|
||||||
'..',
|
'..',
|
||||||
),
|
),
|
||||||
|
array(
|
||||||
|
array(new Token('string', '#foo', 1)),
|
||||||
|
"'#foo'",
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(new Token('string', '#foo', 1)),
|
||||||
|
'"#foo"',
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user