From b32fab16efb715568f54781bcc9e14e30ce41bff Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sat, 24 Aug 2013 12:08:54 -0400
Subject: [PATCH] Fix handling of non-default date formats (#1489294) - remove ambiguous m/d/Y format from default config
---
program/lib/Roundcube/rcube_utils.php | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/program/lib/Roundcube/rcube_utils.php b/program/lib/Roundcube/rcube_utils.php
index cf87ded..2540f77 100644
--- a/program/lib/Roundcube/rcube_utils.php
+++ b/program/lib/Roundcube/rcube_utils.php
@@ -739,11 +739,22 @@
*/
public static function strtotime($date)
{
+ $date = trim($date);
+
// check for MS Outlook vCard date format YYYYMMDD
- if (preg_match('/^([12][90]\d\d)([01]\d)(\d\d)$/', trim($date), $matches)) {
- return mktime(0,0,0, intval($matches[2]), intval($matches[3]), intval($matches[1]));
+ if (preg_match('/^([12][90]\d\d)([01]\d)([0123]\d)$/', $date, $m)) {
+ return mktime(0,0,0, intval($m[2]), intval($m[3]), intval($m[1]));
}
- else if (is_numeric($date)) {
+
+ // common little-endian formats, e.g. dd/mm/yyyy (not all are supported by strtotime)
+ if (preg_match('/^(\d{1,2})[.\/-](\d{1,2})[.\/-](\d{4})$/', $date, $m)
+ && $m[1] > 0 && $m[1] <= 31 && $m[2] > 0 && $m[2] <= 12 && $m[3] >= 1970
+ ) {
+ return mktime(0,0,0, intval($m[2]), intval($m[1]), intval($m[3]));
+ }
+
+ // unix timestamp
+ if (is_numeric($date)) {
return (int) $date;
}
--
Gitblit v1.9.1