Skip to content

Commit c00d9db

Browse files
Fix Date parsing on non-standard format from Aqua Mail (#575)
fixes issue #574
1 parent 0e75d7e commit c00d9db

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Header.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,7 @@ private function read_attribute(string $raw_attribute): array {
673673
* | Thu, 31 May 2018 18:15:00 +0800 (added by) | Non-standard details added by the | Unknown
674674
* | | mail server |
675675
* | Sat, 31 Aug 2013 20:08:23 +0580 | Invalid timezone | PHPMailer bug https://sourceforge.net/p/phpmailer/mailman/message/6132703/
676+
* | Mi., 23 Apr. 2025 09:48:37 +0200 (MESZ) | Non-standard localized format | Aqua Mail S/MIME implementation
676677
*
677678
* Please report any new invalid timestamps to [#45](https://github.com/Webklex/php-imap/issues)
678679
*
@@ -720,8 +721,8 @@ private function parseDate(object $header): void {
720721
case preg_match('/([A-Z]{2,3}\,\ [0-9]{1,2}[\,]\ [A-Z]{2,3}\ [0-9]{4}\ [0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}\ [\-|\+][0-9]{4})+$/i', $date) > 0:
721722
$date = str_replace(',', '', $date);
722723
break;
723-
// match case for: Di., 15 Feb. 2022 06:52:44 +0100 (MEZ)/Di., 15 Feb. 2022 06:52:44 +0100 (MEZ)
724-
case preg_match('/([A-Z]{2,3}\.\,\ [0-9]{1,2}\ [A-Z]{2,3}\.\ [0-9]{4}\ [0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}\ [\-|\+][0-9]{4}\ \([A-Z]{3,4}\))\/([A-Z]{2,3}\.\,\ [0-9]{1,2}\ [A-Z]{2,3}\.\ [0-9]{4}\ [0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}\ [\-|\+][0-9]{4}\ \([A-Z]{3,4}\))+$/i', $date) > 0:
724+
// match case for: Di., 15 Feb. 2022 06:52:44 +0100 (MEZ)/Di., 15 Feb. 2022 06:52:44 +0100 (MEZ) and Mi., 23 Apr. 2025 09:48:37 +0200 (MESZ)
725+
case preg_match('/([A-Z]{2,3}\.\,\ [0-9]{1,2}\ [A-Z]{2,3}\.\ [0-9]{4}\ [0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}\ [\-|\+][0-9]{4}\ \([A-Z]{3,4}\))(\/([A-Z]{2,3}\.\,\ [0-9]{1,2}\ [A-Z]{2,3}\.\ [0-9]{4}\ [0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}\ [\-|\+][0-9]{4}\ \([A-Z]{3,4}\))+)?$/i', $date) > 0:
725726
$dates = explode('/', $date);
726727
$date = array_shift($dates);
727728
$array = explode(',', $date);

tests/fixtures/DateTemplateTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class DateTemplateTest extends FixtureTestCase {
5151
"Thur, 16 Mar 2023 15:33:07 +0400" => "2023-03-16 11:33:07",
5252
"fr., 25 nov. 2022 06:27:14 +0100/fr., 25 nov. 2022 06:27:14 +0100" => "2022-11-25 05:27:14",
5353
"Di., 15 Feb. 2022 06:52:44 +0100 (MEZ)/Di., 15 Feb. 2022 06:52:44 +0100 (MEZ)" => "2022-02-15 05:52:44",
54+
"Mi., 23 Apr. 2025 09:48:37 +0200 (MESZ)" => "2025-04-23 07:48:37",
5455
];
5556

5657
/**

0 commit comments

Comments
 (0)