Skip to content

Commit

Permalink
fixed Zend_Date::ISO_8601 validation (Shardj#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
develart-projects committed Aug 10, 2023
1 parent 787c991 commit 14e968d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions library/Zend/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -1918,6 +1918,13 @@ private function _calculate($calc, $date, $part, $locale)

// date strings
case self::ISO_8601:

// do we have enough of a date? minimum is YYMMdd
if( strlen($date) <6) {
require_once 'Zend/Date/Exception.php';
throw new Zend_Date_Exception("unsupported ISO8601 format ($date)", 0, null, $date);
}

// (-)YYYY-MM-dd
preg_match('/^(-{0,1}\d{4})-(\d{2})-(\d{2})/', $date, $datematch);
// (-)YY-MM-dd
Expand Down Expand Up @@ -1954,10 +1961,10 @@ private function _calculate($calc, $date, $part, $locale)
if (empty($timematch)) {
preg_match('/[T,\s]{0,1}(\d{2})(\d{2})/', $tmpdate, $timematch);
}
if (empty($datematch) && empty($timematch)) {
require_once 'Zend/Date/Exception.php';
throw new Zend_Date_Exception("unsupported ISO8601 format ($date)", 0, null, $date);
}
if (empty($datematch) && empty($timematch)) {
require_once 'Zend/Date/Exception.php';
throw new Zend_Date_Exception("unsupported ISO8601 format ($date)", 0, null, $date);
}
if (!empty($timematch)) {
$timeMatchCharCount = iconv_strlen($timematch[0], 'UTF-8');
$tmpdate = iconv_substr($tmpdate,
Expand Down

0 comments on commit 14e968d

Please sign in to comment.