Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[ExpressionLanguage] Fixed an issue with # characters in double quote…
…d string literals
  • Loading branch information
pylebecq committed Jul 22, 2014
1 parent dfabc4a commit 0c2622e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/ExpressionLanguage/Lexer.php
Expand Up @@ -69,7 +69,7 @@ public function tokenize($expression)

$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]);
Expand Down
8 changes: 8 additions & 0 deletions src/Symfony/Component/ExpressionLanguage/Tests/LexerTest.php
Expand Up @@ -78,6 +78,14 @@ public function getTokenizeData()
array(new Token('operator', '..', 1)),
'..',
),
array(
array(new Token('string', '#foo', 1)),
"'#foo'",
),
array(
array(new Token('string', '#foo', 1)),
'"#foo"',
),
);
}
}

0 comments on commit 0c2622e

Please sign in to comment.