cvs: pear /Validate Validate.php

From: Date: Sun, 09 Jun 2002 16:06:57 +0000
Subject: cvs: pear /Validate Validate.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-4508@lists.php.net to get a copy of this message
cox Sun Jun 9 12:06:57 2002 EDT Modified files: /pear/Validate Validate.php Log: - Fixed year validation - Don't allow remaining data after the parsing Index: pear/Validate/Validate.php diff -u pear/Validate/Validate.php:1.16 pear/Validate/Validate.php:1.17 --- pear/Validate/Validate.php:1.16 Sun Jun 9 11:29:45 2002 +++ pear/Validate/Validate.php Sun Jun 9 12:06:57 2002 @@ -18,7 +18,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: Validate.php,v 1.16 2002/06/09 15:29:45 cox Exp $ +// $Id: Validate.php,v 1.17 2002/06/09 16:06:57 cox Exp $ // // Methods for common data validations // @@ -180,7 +180,7 @@ if (is_array($date)) { extract($date); } - for ($i = 0; $i < strlen($format) && strlen($date); $i++) { + for ($i = 0; $i < strlen($format); $i++) { $c = $format{$i}; if ($c == '%') { $next = $format{$i + 1}; @@ -212,10 +212,10 @@ if ($next == 'Y') { $year = (int)Validate::_substr($date, 4); } else { - $year = (int)(substr(date('Y'), 2) . + $year = (int)(substr(date('Y'), 0, 2) . Validate::_substr($date, 2)); } - if ($year < 0 || $year > 9999) { + if (strlen($year) != 4 || $year < 0 || $year > 9999) { return false; } break; @@ -258,6 +258,10 @@ return false; } } + } + // there is remaing data, we don't want it + if (strlen($date)) { + return false; } if (isset($day) && isset($month) && isset($year)) { include_once 'Date/Calc.php';

« previous php.pear.cvs (#4508) next »