From 956cc7a2cfe2d731f21f4dc552b417479c59a67e Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Sat, 29 Jan 2011 17:05:02 +0000 Subject: [PATCH] Bugfix: Work item 11576 - AdvancedValueBinder.php: String sometimes becomes a date when it shouldn't. Improved with a preg_match trap to reject unlikely formats for dates before passing value to PHPExcel_Shared_Date::stringToExcel() for final validation git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@67536 2327b42d-5241-43d6-9e2a-de5ac946f064 --- Classes/PHPExcel/Shared/Date.php | 2 ++ changelog.txt | 1 + 2 files changed, 3 insertions(+) diff --git a/Classes/PHPExcel/Shared/Date.php b/Classes/PHPExcel/Shared/Date.php index 18e42c11..065ebe79 100644 --- a/Classes/PHPExcel/Shared/Date.php +++ b/Classes/PHPExcel/Shared/Date.php @@ -279,6 +279,8 @@ class PHPExcel_Shared_Date public static function stringToExcel($dateValue = '') { if (strlen($dateValue) < 2) return false; + if (!preg_match('/^(\d{1,4}[ \.\/\-][A-Z]{3,9}([ \.\/\-]\d{1,4})?|[A-Z]{3,9}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?|\d{1,4}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?)( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/iu', $dateValue)) + return false; $dateValueNew = PHPExcel_Calculation_DateTime::DATEVALUE($dateValue); diff --git a/changelog.txt b/changelog.txt index 969d4e9d..94b0d7ad 100644 --- a/changelog.txt +++ b/changelog.txt @@ -51,6 +51,7 @@ Fixed in SVN: - Bugfix: (MBaker) Work item 15129 - Worksheet fromArray() only working with 2-D arrays - Bugfix: (MBaker) Work item 15172 - rangeToarray function modified for non-existent cells - Bugfix: (MBaker) Work item 14980 - Images not getting copyied with the ->clone function +- Bugfix: (MBaker) Work item 11576 - AdvancedValueBinder.php: String sometimes becomes a date when it shouldn't - General: (MBaker) Improved performance (speed), for building the Shared Strings table in the Excel2007 Writer.