[ExpressionLanguage] Fixed an issue with # characters in double quoted string literals

This commit is contained in:
Pierre-Yves LEBECQ 2014-07-22 15:26:16 +02:00
parent dfabc4a61a
commit 0c2622e2e7
2 changed files with 9 additions and 1 deletions

View File

@ -69,7 +69,7 @@ class Lexer
$tokens[] = new Token(Token::PUNCTUATION_TYPE, $expression[$cursor], $cursor + 1);
++$cursor;
} elseif (preg_match('/"([^#"\\\\]*(?:\\\\.[^#"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As', $expression, $match, null, $cursor)) {
} elseif (preg_match('/"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As', $expression, $match, null, $cursor)) {
// strings
$tokens[] = new Token(Token::STRING_TYPE, stripcslashes(substr($match[0], 1, -1)), $cursor + 1);
$cursor += strlen($match[0]);

View File

@ -78,6 +78,14 @@ class LexerTest extends \PHPUnit_Framework_TestCase
array(new Token('operator', '..', 1)),
'..',
),
array(
array(new Token('string', '#foo', 1)),
"'#foo'",
),
array(
array(new Token('string', '#foo', 1)),
'"#foo"',
),
);
}
}