[BUGFIX] DateValidator fails to validate incorrect dates 69/36469/2
authorNicole Cordes <typo3@cordes.co>
Fri, 30 Jan 2015 18:35:11 +0000 (19:35 +0100)
committerSteffen Müller <typo3@t3node.com>
Fri, 30 Jan 2015 19:22:11 +0000 (20:22 +0100)
If the function "strptime" is not present in the environment (mostly on
Windows systems) the fallback to check a given date in the dateValidator
fails to detect invalid dates. The conversion from the given string to
a date object respects invalid dates and just converts them to valid
ones (by moving in next month/year). Therefore the function returns an
object instead of false. This patch adds a value comparison between old
and new value to be sure still the same date string is returned.

Releases: master, 6.2
Resolves: #64661
Change-Id: I739d309278143bb5fc24c48ca7bb884a1e25a442
Reviewed-on: http://review.typo3.org/36469
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Steffen Müller <typo3@t3node.com>
Tested-by: Steffen Müller <typo3@t3node.com>
typo3/sysext/form/Classes/Validation/DateValidator.php

index 5afd1b9..42b79da 100644 (file)
@@ -77,7 +77,12 @@ class DateValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator {
                                        array('D', 'l', 'd', 'j', 'z', 'M', 'F', 'M', 'm', 'y', 'Y'),
                                        $this->format
                                );
-                               return date_create_from_format($dateTimeFormat, $value) !== FALSE;
+                               $dateTimeObject = date_create_from_format($dateTimeFormat, $value);
+                               if ($dateTimeObject === FALSE) {
+                                       return FALSE;
+                               }
+
+                               return $value === $dateTimeObject->format($dateTimeFormat);
                        }
                }
                return TRUE;