Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Handle invalid dates in the user modules

  • Loading branch information...
commit 03fd7fbe69005f87e01eed7464ef7ee6dcb54f4d 1 parent 2576ef9
@leofeyer leofeyer authored
View
13 system/modules/frontend/ModulePersonalData.php
@@ -166,9 +166,16 @@ protected function compile()
// Convert date formats into timestamps (check the eval setting first -> #3063)
if (($rgxp == 'date' || $rgxp == 'time' || $rgxp == 'datim') && $varValue != '')
{
- // Use the numeric back end format here!
- $objDate = new Date($varValue, $GLOBALS['TL_CONFIG'][$rgxp.'Format']);
- $varValue = $objDate->tstamp;
+ try
+ {
+ // Use the numeric back end format here!
+ $objDate = new Date($varValue, $GLOBALS['TL_CONFIG'][$rgxp.'Format']);
+ $varValue = $objDate->tstamp;
+ }
+ catch (Exception $e)
+ {
+ $objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $varValue));
+ }
}
// Make sure that unique fields are unique (check the eval setting first -> #3063)
View
13 system/modules/registration/ModuleRegistration.php
@@ -208,9 +208,16 @@ protected function compile()
// Convert date formats into timestamps (check the eval setting first -> #3063)
if (($rgxp == 'date' || $rgxp == 'time' || $rgxp == 'datim') && $varValue != '')
{
- // Use the numeric back end format here!
- $objDate = new Date($varValue, $GLOBALS['TL_CONFIG'][$rgxp.'Format']);
- $varValue = $objDate->tstamp;
+ try
+ {
+ // Use the numeric back end format here!
+ $objDate = new Date($varValue, $GLOBALS['TL_CONFIG'][$rgxp.'Format']);
+ $varValue = $objDate->tstamp;
+ }
+ catch (Exception $e)
+ {
+ $objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $varValue));
+ }
}
// Make sure that unique fields are unique (check the eval setting first -> #3063)
Please sign in to comment.
Something went wrong with that request. Please try again.