-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[ExpressionLanguage] Fix matches when the regexp is not valid #45875
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
fabpot
commented
Mar 28, 2022
Q | A |
---|---|
Branch? | 4.4 |
Bug fix? | yes |
New feature? | no |
Deprecations? | no |
Tickets | n/a |
License | MIT |
Doc PR | n/a |
src/Symfony/Component/ExpressionLanguage/Tests/Node/BinaryNodeTest.php
Outdated
Show resolved
Hide resolved
22f81a7
to
b2da2f8
Compare
nicolas-grekas
approved these changes
Mar 30, 2022
b2da2f8
to
f09da16
Compare
This was referenced Apr 2, 2022
Merged
Merged
Merged
This was referenced Apr 3, 2022
fabpot
added a commit
that referenced
this pull request
Apr 3, 2022
…xpression (ausi) This PR was squashed before being merged into the 4.4 branch. Discussion ---------- [ExpressionLanguage] Fix matching null against a regular expression | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #45926 | License | MIT | Doc PR | - As discussed in #45926 (comment) The bug was introduced by #45875 Commits ------- 3326da0 [ExpressionLanguage] Fix matching null against a regular expression
fabpot
added a commit
that referenced
this pull request
Oct 6, 2024
…g used as regexp (ivantsepp) This PR was squashed before being merged into the 7.2 branch. Discussion ---------- [ExpressionLanguage] Fix matches to handle booleans being used as regexp | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | n/a | License | MIT I'm marking this as a bug fix but this could be seen as a "new feature" as existing `matches` syntax functionality works just fine. I wanted to build on top of the work done at #45875. This handles invalid regular expressions and also does an extra check inside the `compile` method. It checks the right hand side for a `ConstantNode` and validates that it's a valid regexp. The idea is that we can go **even further** and check for `BinaryNode` because in most cases, this is an invalid regexp since a boolean usually returned. The exception is `~` which is for string concatenation since that could result in a valid regexp. This extra check could help prevent invalid expressions like `"a" matches ("/a/" || "/b/")` where one could mistake `"/a/" || "/b/"` as being a valid regexp (when the correct approach would've been `"a" matches "/a|b/"`) Commits ------- e0fbc7e [ExpressionLanguage] Fix matches to handle booleans being used as regexp
symfony-splitter
pushed a commit
to symfony/expression-language
that referenced
this pull request
Oct 6, 2024
…g used as regexp (ivantsepp) This PR was squashed before being merged into the 7.2 branch. Discussion ---------- [ExpressionLanguage] Fix matches to handle booleans being used as regexp | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | n/a | License | MIT I'm marking this as a bug fix but this could be seen as a "new feature" as existing `matches` syntax functionality works just fine. I wanted to build on top of the work done at symfony/symfony#45875. This handles invalid regular expressions and also does an extra check inside the `compile` method. It checks the right hand side for a `ConstantNode` and validates that it's a valid regexp. The idea is that we can go **even further** and check for `BinaryNode` because in most cases, this is an invalid regexp since a boolean usually returned. The exception is `~` which is for string concatenation since that could result in a valid regexp. This extra check could help prevent invalid expressions like `"a" matches ("/a/" || "/b/")` where one could mistake `"/a/" || "/b/"` as being a valid regexp (when the correct approach would've been `"a" matches "/a|b/"`) Commits ------- e0fbc7ee02 [ExpressionLanguage] Fix matches to handle booleans being used as regexp
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.