Problem/Motivation
The Token API uses this regex to match and assemble a list of tokens in a string:
// Matches tokens with the following pattern: [$type:$name]
// $type and $name may not contain [ ] characters.
// $type may not contain : or whitespace characters, but $name may.
preg_match_all('/
\[ # [ - pattern start
([^\s\[\]:]*) # match $type not containing whitespace : [ or ]
: # : - separator
([^\[\]]*) # match $name not containing [ or ]
\] # ] - pattern end
/x', $text, $matches);
It uses the * character which will match zero or more characters, meaning it will match empty token types or tokens, which could lead to unexpected results.
Beta phase evaluation
Proposed resolution
Use the + repetition character (1 or more) rather than * (0 or more).
Remaining tasks
Contributor tasks needed
| Task |
Novice task? |
Contributor instructions |
Complete? |
| Review patch to ensure that it fixes the issue, stays within scope, is properly documented, and follows coding standards |
Novice |
Instructions |
|
User interface changes
None.
API changes
None.
Comments
Comment #1
xjmComment #3
jibranThank you seems straight forward so RTBC.
Comment #4
alexpottCommitted 62ba78d and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation for to the issue summary.