Skip to content
Snippets Groups Projects
Commit 091658d3 authored by Nicole Cordes's avatar Nicole Cordes Committed by Steffen Müller
Browse files

[BUGFIX] DateValidator fails to validate incorrect dates

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/36467


Reviewed-by: default avatarOliver Klee <typo3-coding@oliverklee.de>
Tested-by: default avatarOliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: default avatarSteffen Müller <typo3@t3node.com>
Tested-by: default avatarSteffen Müller <typo3@t3node.com>
parent 0aeb2937
Branches
Tags
No related merge requests found
......@@ -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;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment