You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
minor symfony#58261 [ExpressionLanguage] Fix matches to handle booleans being 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#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
0 commit comments