Skip to content

Commit

Permalink
Don't fail if a client sends a bad date, just ignore it.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Mar 3, 2015
1 parent bb52fdb commit aa54aba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions framework/ActiveSync/lib/Horde/ActiveSync/Message/Base.php
Expand Up @@ -563,15 +563,17 @@ protected function _formatDate(Horde_Date $dt, $type)
*
* @param string $ts The timestamp
*
* @return Horde_Date The Horde_Date
* @return Horde_Date|boolean The Horde_Date or false if unable to decode.
*/
protected function _parseDate($ts)
{
if (preg_match("/(\d{4})[^0-9]*(\d{2})[^0-9]*(\d{2})(T(\d{2})[^0-9]*(\d{2})[^0-9]*(\d{2})(.\d+)?Z){0,1}$/", $ts, $matches)) {
return new Horde_Date($ts);
try {
return new Horde_Date($ts);
} catch (Horde_Date_Exception $e) {}
}

throw new Horde_ActiveSync_Exception('Invalid date format');
return false;
}

/**
Expand Down
Expand Up @@ -394,11 +394,13 @@ protected function _checkSendEmpty($tag)
*
* @param string $ts The timestamp
*
* @return Horde_Date The Horde_Date object, in UTC.
* @return Horde_Date|boolean The Horde_Date object (UTC) or false if
* unable to parse the date.
*/
protected function _parseDate($ts)
{
$date = parent::_parseDate($ts);

// Since some clients send the date as YYYY-MM-DD only, the best we can
// do is assume that it is in the same timezone as the user's default
// timezone - so convert it to UTC and be done with it.
Expand Down

0 comments on commit aa54aba

Please sign in to comment.