Re: potential PEAR::Validate bug (in date method)

From: Date: Thu, 22 Jan 2004 13:06:28 +0000
Subject: Re: potential PEAR::Validate bug (in date method)
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-25226@lists.php.net to get a copy of this message
Maybe adding a "is_int"-check would also suffice. But I like that Validate::number-solution somehow. :-) Stefan On Thu, 22 Jan 2004 at 14:00:22, B. Kamer wrote: > Hi, I also may have found a bug. > > please tell me if I should report this bug (if is is one) and if or how > to > > $aTime = "DF:df"; > $isTime = Validate::date( $aTime, array( 'format'=>"%H:%i") ); > this passes; > > a possible fix > > thx > > change the date method from line 269 > ========================= > case 'g': > case 'h': > if ($next == 'g') { > $hour = Validate::_substr($date, 1, 2); > } else { > $hour = Validate::_substr($date, 2); > } > if ($hour < 0 || $hour > 12) { > return false; > } > break; > case 'G': > case 'H': > if ($next == 'G') { > $hour = Validate::_substr($date, 1, 2); > } else { > $hour = Validate::_substr($date, 2); > } > if ($hour < 0 || $hour > 24) { > return false; > } > break; > case 's': > case 'i': > $t = Validate::_substr($date, 2); > if ($t < 0 || $t > 59) { > return false; > } > break; > ========================= > into > ========================= > case 'g': > case 'h': > if ($next == 'g') { > $hour = Validate::_substr($date, 1, 2); > } else { > $hour = Validate::_substr($date, 2); > } > if (!Validate::number($hour, array('decimal'=>false, 'min'=>0, > 'max'=>12))) { > return false; > } > break; > case 'G': > case 'H': > if ($next == 'G') { > $hour = Validate::_substr($date, 1, 2); > } else { > $hour = Validate::_substr($date, 2); > } > if (!Validate::number($hour, array('decimal'=>false, 'min'=>0, > 'max'=>23))) { > return false; > } > break; > case 's': > case 'i': > $t = Validate::_substr($date, 2); > > if (!Validate::number($t, array('decimal'=>false, 'min'=>0, > 'max'=>59))) { > return false; > } > break; > =========================

« previous php.pear.dev (#25226) next »