-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[ExpressionLanguage] Fixed collisions of character operators with object properties #35707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ExpressionLanguage] Fixed collisions of character operators with object properties #35707
Conversation
60868aa
to
2b3d8e0
Compare
I suppose the same issue exists on 3.4? Can you please rebase+retarget the PR if confirmed? |
2b3d8e0
to
6ae75b6
Compare
6ae75b6
to
cdfc4ea
Compare
@nicolas-grekas Yes you are right, my mistake. I retarget the PR. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See twigphp/Twig#3276 for a similar in Twig.
// - an operator that begins with a character must not be following after dot | ||
// - an operator that ends with a character must be followed by a whitespace or a parenthesis | ||
$regex[] = | ||
(ctype_alpha($operator[$length - 1]) ? '(?<!\.)' : '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be $operator[0]
as we want to test the first character as per the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the test should be that a whitespace must be before the operator to cover other cases like foo|not in ...
. So the regex should be (?=[\s()])
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the test should be that a whitespace must be before the operator to cover other cases
Using whitespace incorrect work on case when operator in the start of expression - not foo
.
Test https://github.com/symfony/symfony/pull/35707/files#diff-20d6647365cfcd9f6114d806f45a4771R184
I don't known Twig lexer, I will check this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong copy/pasting on the regex, should be (?<=[\s(])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(?<=[\s(])not(?=[\s(])
not matched first not in case not foo.not or not bar.not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(?<=^|[\s(])
- works. I will fix it. Thank you.
src/Symfony/Component/ExpressionLanguage/Resources/bin/generate_operator_regex.php
Outdated
Show resolved
Hide resolved
dd3eaf8
to
4b83ae7
Compare
Thank you @Andrej-in-ua. |
Expression
foo.not in [bar]
compiles to invalid php code:Added check for absence of a dot before of the character operators.
PS. I apologize for not starting the issue before create PR. I considered this bug is minor, but obvious.