bug #11439 [ExpressionLanguage] Fixed double quoted string literals containing sharps (pylebecq)
This PR was merged into the 2.4 branch.
Discussion
----------
[ExpressionLanguage] Fixed double quoted string literals containing sharps
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #11433
| License | MIT
| Doc PR | n/a
Commits
-------
0c2622e
[ExpressionLanguage] Fixed an issue with # characters in double quoted string literals
This commit is contained in:
commit
0032abd618
@ -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