Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Bug in SmartyValidate 2.8/2.9

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
sguillory6
Smarty Rookie


Joined: 20 Feb 2006
Posts: 17

PostPosted: Tue Aug 14, 2007 1:28 pm    Post subject: Bug in SmartyValidate 2.8/2.9 Reply with quote

There is a bug in SmartyValidate 2.8 (I use 2.8, but I examined the 2.9 source and it exists there also) involving multi-field validators. If you have a situation like this:

SmartyValidate::register_validator("minShipDate", "shipDate", "minShipDate",
true, false, "trim", 'step3form');
SmartyValidate::register_validator("validShipCancelPair", "shipDate:cancelDate",
"isValidShipCancelPair", true, false, "trim", 'step3form');


i.e., you register a validator on a field called "shipDate", and then register a multi-field validator that includes the shipDate field, then the following bug can be triggered:

1) An invalid shipDate is entered
2) An valid cancelDate is entered (as determined by the multi-field validator)

3) When SmartyValidate is processing the multi-field validator, it will short-circuit the processing because one of the multiple fields, shipDate, has failed an earlier validation, and marked the validator as failed.

4) I believe the behavior (not verified) of 2.9 is actually the opposite. If you enter an invalid shipDate and an invalid cancelDate, 2.9 will short-circuit the processing of the multi-field validator, but will mark the validator as valid.

Here is the patch to fix 2.8. I believe this will fix 2.9 also, since the short-circuiting the validator to valid needs to be removed.


142a143,144
> // Check if all fields of a multi-field validator have failed previously before
> // short-circuiting this validator
144,145c146,158
< // already failed, skip this test
< continue;
---
> $_go_on = true;
> for ($_idx_ = 2; isset($_sess[$_key]["field" . $_idx_]); $_idx_++) {
> $_field_n = $_sess[$_key]["field" . $_idx_];
>
> if (!in_array($_field_n, $_ret)) {
> $_go_on = false;
> break;
> }
> }
>
> if ($_go_on == true) {
> continue;
> }
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP