Bug #5047

Validationresovler regex fails for more than one validator with options

Added by Nikolas Hagelstein almost 6 years ago. Updated almost 5 years ago.

Status:Resolved Start date:2009-10-20
Priority:Must have Due date:
Assigned To:Karsten Dambekalns % Done:

100%

Category:Validation
Target version:TYPO3 Flow Base Distribution - 1.0 alpha 6
PHP Version: Complexity:
Has patch: Affected Flow version:

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 wi... Resolved 2009-10-30

Associated revisions

Revision 753b0287
Added by Karsten Dambekalns almost 6 years ago

[+BUGFIX] FLOW3 (Validation): Multiple validators with option can now be specified in @validate, fixes #5047.

History

#1 Updated by Karsten Dambekalns almost 6 years ago

  • Category set to Validation
  • Status changed from New to Accepted
  • Assigned To set to Karsten Dambekalns
  • Target version set to 1.0 alpha 6

#2 Updated by Karsten Dambekalns almost 6 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 6 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 6 years ago

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

Applied in changeset r3386.

Also available in: Atom PDF