Bug #5047
Validationresovler regex fails for more than one validator with options
100%
Description
A validation consisting of 2 validations having options makes the regex fail.
E.g.: @validate $whatever stringLength(minimum="5"), bla(abc="123")
Results in (not the options part):
array(1) {
[0]=>
array(5) {
[0]=>
string(41) "stringLength(minimum="5"), bla(abc="123")"
["validatorName"]=>.
string(12) "stringLength"
[1]=>
string(12) "stringLength"
["validatorOptions"]=>
string(27) "minimum="5"), bla(abc="123""
[2]=>
string(27) "minimum="5"), bla(abc="123""
}
}
Changing
const PATTERN_MATCH_VALIDATORS = '/(?:^|,\s*)(?P<validatorName>[a-z0-9\\\\]+)\s*(?:\((?P<validatorOptions>.+)\))?/i';
To
const PATTERN_MATCH_VALIDATORS = '/(?:^|,\s*)(?P<validatorName>[a-z0-9\\\\]+)\s*(?:\((?P<validatorOptions>[^)]+)\))?/i';
Seems to solve this issue. Could anyone please confirm. Thought this might fail as well for something like "bla(myoptions="asfasF)").
see http://forge.typo3.org/issues/show/5046 as well.
Related issues
Updated by Karsten Dambekalns over 11 years ago
- Category set to Validation
- Status changed from New to Accepted
- Assignee set to Karsten Dambekalns
- Target version set to 1.0 alpha 6
Updated by Karsten Dambekalns over 11 years ago
Your suggested fix indeed breaks an existing test (using ")" inside an option value). I'll look into that for alpha6.
Updated by Sebastian Kurfuerst over 11 years ago
Karsten Dambekalns wrote:
Your suggested fix indeed breaks an existing test (using ")" inside an option value). I'll look into that for alpha6.
I've been implementing a lot of this for Fluid:
(?: # either... "(?:\\\"|[^"])*" # a double-quoted string |\'(?:\\\\\'|[^\'])*\' # or a single quoted string )\s* #So, this says:
- Inside double quotes, allow any combination of:
- escaped double quotes
- any other characters except double quote
And for the single-quote case it's the same, just some more escaping because the regex is enclosed in single quotes.
Hope this helps!
Greets, Sebastian
Updated by Karsten Dambekalns over 11 years ago
- Status changed from Accepted to Resolved
- % Done changed from 0 to 100
Applied in changeset r3386.