Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Handle invalid dates in the user modules
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Feb 1, 2013
1 parent 2576ef9 commit 03fd7fb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
13 changes: 10 additions & 3 deletions system/modules/frontend/ModulePersonalData.php
Expand Up @@ -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)
Expand Down
13 changes: 10 additions & 3 deletions system/modules/registration/ModuleRegistration.php
Expand Up @@ -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)
Expand Down

0 comments on commit 03fd7fb

Please sign in to comment.