Bug #5047

Validationresovler regex fails for more than one validator with options

Added by Nikolas Hagelstein almost 12 years ago. Updated almost 11 years ago.

Status:
Resolved
Priority:
Must have
Category:
Validation
Start date:
2009-10-20
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
Complexity:

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

Related to TYPO3.Flow - Bug #5185: ValidatorResolver fails to parse @validate annotations with complex optionsResolvedKarsten Dambekalns2009-10-30

Actions
#1

Updated by Karsten Dambekalns almost 12 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
#2

Updated by Karsten Dambekalns almost 12 years ago

Your suggested fix indeed breaks an existing test (using ")" inside an option value). I'll look into that for alpha6.

#3

Updated by Sebastian Kurfuerst almost 12 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

#4

Updated by Karsten Dambekalns almost 12 years ago

  • Status changed from Accepted to Resolved
  • % Done changed from 0 to 100

Applied in changeset r3386.

Also available in: Atom PDF