Skip to content

Commit

Permalink
Correctly processs invalid dates when fetching emails - closes #4159
Browse files Browse the repository at this point in the history
  • Loading branch information
freescout-help-desk committed Aug 2, 2024
1 parent 02e5fa8 commit 8e62d70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/Console/Commands/ParseEml.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public function handle()
$this->info($message->getInReplyTo());
$this->line('References: ');
$this->info(json_encode(array_values(array_filter(preg_split('/[, <>]/', $message->getReferences() ?? ''))), JSON_UNESCAPED_UNICODE));
$this->line('Date: ');
$this->info($message->getDate());
$this->line('Subject: ');
$this->info($message->getSubject());
$this->line('Text Body: ');
Expand Down
7 changes: 6 additions & 1 deletion overrides/webklex/php-imap/src/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,12 @@ private function parseDate($header) {
$parsed_date = Carbon::parse($date);
} catch (\Exception $_e) {
if (!isset($this->config["fallback_date"])) {
throw new InvalidMessageDateException("Invalid message date. ID:" . $this->get("message_id") . " Date:" . $header->date . "/" . $date, 1100, $e);
// Simply use current date.
// https://github.com/freescout-help-desk/freescout/issues/4159
$parsed_date = Carbon::now();
\Helper::logException(new InvalidMessageDateException("Invalid message date. ID:" . $this->get("message_id") . " Date:" . $header->date . "/" . $date, 1100, $e));

//throw new InvalidMessageDateException("Invalid message date. ID:" . $this->get("message_id") . " Date:" . $header->date . "/" . $date, 1100, $e);
} else {
$parsed_date = Carbon::parse($this->config["fallback_date"]);
}
Expand Down

0 comments on commit 8e62d70

Please sign in to comment.