cvs: pear-core /PEAR Validate.php

From: Date: Thu, 08 Jun 2006 01:22:30 +0000
Subject: cvs: pear-core /PEAR Validate.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-4778@lists.php.net to get a copy of this message
pajoye Thu Jun 8 01:22:30 2006 UTC Modified files: /pear-core/PEAR Validate.php Log: - MFH: #7640, validate the date field format (simplify the method too) http://cvs.php.net/viewcvs.cgi/pear-core/PEAR/Validate.php?r1=1.46&r2=1.47&diff_format=u Index: pear-core/PEAR/Validate.php diff -u pear-core/PEAR/Validate.php:1.46 pear-core/PEAR/Validate.php:1.47 --- pear-core/PEAR/Validate.php:1.46 Mon Jan 23 17:16:35 2006 +++ pear-core/PEAR/Validate.php Thu Jun 8 01:22:30 2006 @@ -15,7 +15,7 @@ * @author Greg Beaver <cellog@php.net> * @copyright 1997-2006 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Validate.php,v 1.46 2006/01/23 17:16:35 cellog Exp $ + * @version CVS: $Id: Validate.php,v 1.47 2006/06/08 01:22:30 pajoye Exp $ * @link http://pear.php.net/package/PEAR * @since File available since Release 1.4.0a1 */ @@ -445,17 +445,18 @@ { if ($this->_state == PEAR_VALIDATE_NORMAL || $this->_state == PEAR_VALIDATE_PACKAGING) { - if (!preg_match('/\d\d\d\d\-\d\d\-\d\d/', - $this->_packagexml->getDate())) { - $this->_addFailure('date', 'invalid release date "' . - $this->_packagexml->getDate() . '"'); - return false; - } - if (strtotime($this->_packagexml->getDate()) == -1) { + + if (!preg_match('/(\d\d\d\d)\-(\d\d)\-(\d\d)/', + $this->_packagexml->getDate(), $res) || + count($res) < 4 + || !checkdate($res[2], $res[3], $res[1]) + ) { $this->_addFailure('date', 'invalid release date "' . $this->_packagexml->getDate() . '"'); return false; } + + if ($this->_state == PEAR_VALIDATE_PACKAGING && $this->_packagexml->getDate() != date('Y-m-d')) { $this->_addWarning('date', 'Release Date "' . @@ -628,4 +629,4 @@ return true; } } -?> \ No newline at end of file +?>

« previous php.pear.core (#4778) next »