From: Alexander Ebert Date: Wed, 12 Mar 2014 16:03:05 +0000 (+0100) Subject: DateUtil::checkDate() now validates all ISO dates X-Git-Tag: 2.0.4~17 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=977f328b2cb686886fcdb132f00ea5895c31e7fc;p=GitHub%2FWoltLab%2FWCF.git DateUtil::checkDate() now validates all ISO dates Fixes #1677 --- diff --git a/wcfsetup/install/files/lib/util/DateUtil.class.php b/wcfsetup/install/files/lib/util/DateUtil.class.php index 496e58a1be..ce6acfd2e7 100644 --- a/wcfsetup/install/files/lib/util/DateUtil.class.php +++ b/wcfsetup/install/files/lib/util/DateUtil.class.php @@ -357,6 +357,12 @@ final class DateUtil { * @param string $date */ public static function validateDate($date) { + if (preg_match('~^(?[0-9]{4})-(?[0-9]{2})-(?[0-9]{2})~', $date, $matches)) { + return checkdate($matches['month'], $matches['day'], $matches['year']); + } + + return false; + // matches almost any valid date between year 2000 and 2038 if (!preg_match('~^(20[0-2][0-9]|203[0-8])\-(0[1-9]|1[0-2])\-(0[1-9]|[1-2][0-9]|3[0-1])$~', $date)) { throw new SystemException("date '".$date."' is invalid, violating ISO-8601 date format.");