-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Routing] make xml loader more tolerant #7268
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
Conversation
schemes and methods may also be delimited by whitespace, comma or pipe. this eases migration as now schemes="GET|POST" also works
$schemes = array_filter(explode(' ', $node->getAttribute('schemes'))); | ||
$methods = array_filter(explode(' ', $node->getAttribute('methods'))); | ||
$schemes = preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, PREG_SPLIT_NO_EMPTY); | ||
$methods = preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, PREG_SPLIT_NO_EMPTY); |
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.
why 2 +
?
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.
It prevents backtracking. So its a performance thing (which I also implemented for UrlMatching/route compiling some time ago).
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.
I would say it's a micro-optim which:
- makes the code unclear,
- is really useless as you want to use the compiled version where perf matters.
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.
Well its standard syntax for regular expressions. Just less known.
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.
btw where could there be any backtracking here ?
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.
(but thanks for the tip++ anyway!)
This PR was merged into the 2.2 branch. Commits ------- 54c333d [Routing] unify and fix the loader tests 41ad9d8 [Routing] make xml loader more tolerant Discussion ---------- [Routing] make xml loader more tolerant schemes and methods may also be delimited by whitespace, comma or pipe. Fixes #6049 (comment) this eases migration as now `methods="GET|POST"` also works the second commit unifies the tests and fixes some strange assertions that were useless | Q | A | ------------- | --- | Bug fix? | [yes] | New feature? | [yes but not really] | BC breaks? | [no] | Deprecations? | [no] | Tests pass? | [yes] | License | MIT
schemes and methods may also be delimited by whitespace, comma or pipe.
Fixes #6049 (comment)
this eases migration as now
methods="GET|POST"
also worksthe second commit unifies the tests and fixes some strange assertions that were useless