-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: detect imip messages from outlook.com
Adjust the parsing logic in MessageMapper to correctly detect iMIP messages in flat email structures where the text/calendar part is not wrapped in multipart/alternative. Signed-off-by: Daniel Kesselberg <[email protected]>
- Loading branch information
1 parent
374fb45
commit 974cca8
Showing
5 changed files
with
178 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -593,4 +593,45 @@ public function testGetFlaggedSearchResultUnexpectedStructure() { | |
$result = $this->mapper->getFlagged($imapClient, $mailbox, $flag); | ||
$this->assertEquals($result, []); | ||
} | ||
|
||
/** | ||
* This test ensures that we correctly identify iMIP messages from various | ||
* sources as valid iMIP messages. The test cases are based on original | ||
* iMIP messages from different vendors. The focus is on the MIME message | ||
* structure and verifying that we traverse the MIME tree properly. | ||
* | ||
* @dataProvider isImipMessageProvider | ||
*/ | ||
public function testGetBodyStructureIsImipMessage(string $filename, bool $expected): void { | ||
$text = file_get_contents(__DIR__ . '/../../data/imip/' . $filename . '.txt'); | ||
$part = \Horde_Mime_Part::parseMessage($text); | ||
|
||
$fetchData = new Horde_Imap_Client_Data_Fetch(); | ||
$fetchData->setStructure($part); | ||
$fetchData->setUid(100); | ||
|
||
$fetchResult = new Horde_Imap_Client_Fetch_Results(); | ||
$fetchResult[0] = $fetchData; | ||
|
||
$imapClient = $this->createMock(Horde_Imap_Client_Socket::class); | ||
$imapClient->method('fetch') | ||
->willReturn($fetchResult); | ||
|
||
$data = $this->mapper->getBodyStructureData( | ||
$imapClient, | ||
'INBOX', | ||
[100], | ||
'[email protected]' | ||
); | ||
|
||
$this->assertCount(1, $data); | ||
$this->assertEquals($expected, $data[0]->isImipMessage()); | ||
} | ||
|
||
public function isImipMessageProvider(): array { | ||
return [ | ||
'google request' => ['request_google', true], | ||
'outlook.com request' => ['request_outlook_com', true], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
MIME-Version: 1.0 | ||
Message-ID: <[email protected]> | ||
Date: Thu, 06 Feb 2025 16:21:41 +0000 | ||
From: [email protected] | ||
To: [email protected], [email protected] | ||
Content-Type: multipart/mixed; boundary="f2d8330e8efc4039bd8073c70ec6cf24" | ||
Subject: Invitation: Imip Testing @ Thu Feb 20, 2025 7pm - 8pm | ||
(CET) ([email protected]) | ||
|
||
--f2d8330e8efc4039bd8073c70ec6cf24 | ||
Content-Type: multipart/alternative; boundary="f55a70234308486098b936b62a6d5e33" | ||
|
||
--f55a70234308486098b936b62a6d5e33 | ||
Content-Type: text/plain; charset="UTF-8"; format=flowed; delsp=yes | ||
Content-Transfer-Encoding: base64 | ||
|
||
SW1pcCBUZXN0aW5nICh0ZXh0L3BsYWluKQo= | ||
--f55a70234308486098b936b62a6d5e33 | ||
Content-Type: text/calendar; charset="UTF-8"; method=REQUEST | ||
Content-Transfer-Encoding: 7bit | ||
|
||
BEGIN:VCALENDAR | ||
PRODID:-//Google Inc//Google Calendar 70.9054//EN | ||
VERSION:2.0 | ||
CALSCALE:GREGORIAN | ||
METHOD:REQUEST | ||
BEGIN:VTIMEZONE | ||
TZID:Europe/Berlin | ||
X-LIC-LOCATION:Europe/Berlin | ||
BEGIN:DAYLIGHT | ||
TZOFFSETFROM:+0100 | ||
TZOFFSETTO:+0200 | ||
TZNAME:GMT+2 | ||
DTSTART:19700329T020000 | ||
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU | ||
END:DAYLIGHT | ||
BEGIN:STANDARD | ||
TZOFFSETFROM:+0200 | ||
TZOFFSETTO:+0100 | ||
TZNAME:GMT+1 | ||
DTSTART:19701025T030000 | ||
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU | ||
END:STANDARD | ||
END:VTIMEZONE | ||
BEGIN:VEVENT | ||
DTSTART;TZID=Europe/Berlin:20250220T190000 | ||
DTEND;TZID=Europe/Berlin:20250220T200000 | ||
DTSTAMP:20250206T162141Z | ||
ORGANIZER;[email protected]:mailto:[email protected] | ||
UID:[email protected] | ||
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP= | ||
TRUE;[email protected];X-NUM-GUESTS=0:mailto:[email protected] | ||
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;RSVP=TRUE | ||
;[email protected];X-NUM-GUESTS=0:mailto:[email protected] | ||
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP= | ||
TRUE;[email protected];X-NUM-GUESTS=0:mailto:[email protected] | ||
CREATED:20250206T162140Z | ||
DESCRIPTION: | ||
LAST-MODIFIED:20250206T162140Z | ||
LOCATION: | ||
SEQUENCE:0 | ||
STATUS:CONFIRMED | ||
SUMMARY:Imip Testing | ||
TRANSP:OPAQUE | ||
BEGIN:VALARM | ||
ACTION:DISPLAY | ||
DESCRIPTION:This is an event reminder | ||
TRIGGER:-P0DT0H30M0S | ||
END:VALARM | ||
END:VEVENT | ||
END:VCALENDAR | ||
|
||
--f55a70234308486098b936b62a6d5e33-- | ||
--f2d8330e8efc4039bd8073c70ec6cf24-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
From: [email protected] | ||
To: [email protected], [email protected] | ||
Date: Thu, 6 Feb 2025 10:26:13 +0000 | ||
Message-ID: <[email protected]> | ||
Accept-Language: en-US, de-DE | ||
Content-Language: en-US | ||
Content-Type: multipart/alternative; | ||
boundary="a6ccc118fe8d4081837903c834923d7a" | ||
MIME-Version: 1.0 | ||
Subject: Imip Testing | ||
|
||
--a6ccc118fe8d4081837903c834923d7a | ||
Content-Type: text/plain; charset="iso-8859-1" | ||
Content-Transfer-Encoding: quoted-printable | ||
|
||
|
||
|
||
--a6ccc118fe8d4081837903c834923d7a | ||
Content-Type: text/html; charset="iso-8859-1" | ||
Content-Transfer-Encoding: quoted-printable | ||
|
||
|
||
--a6ccc118fe8d4081837903c834923d7a | ||
Content-Type: text/calendar; charset="utf-8"; method=REQUEST | ||
Content-Transfer-Encoding: base64 | ||
|
||
QkVHSU46VkNBTEVOREFSCk1FVEhPRDpSRVFVRVNUClBST0RJRDpNaWNyb3NvZnQgRXhjaGFuZ2Ug | ||
U2VydmVyIDIwMTAKVkVSU0lPTjoyLjAKQkVHSU46VlRJTUVaT05FClRaSUQ6Vy4gRXVyb3BlIFN0 | ||
YW5kYXJkIFRpbWUKQkVHSU46U1RBTkRBUkQKRFRTVEFSVDoxNjAxMDEwMVQwMzAwMDAKVFpPRkZT | ||
RVRGUk9NOiswMjAwClRaT0ZGU0VUVE86KzAxMDAKUlJVTEU6RlJFUT1ZRUFSTFk7SU5URVJWQUw9 | ||
MTtCWURBWT0tMVNVO0JZTU9OVEg9MTAKRU5EOlNUQU5EQVJECkJFR0lOOkRBWUxJR0hUCkRUU1RB | ||
UlQ6MTYwMTAxMDFUMDIwMDAwClRaT0ZGU0VURlJPTTorMDEwMApUWk9GRlNFVFRPOiswMjAwClJS | ||
VUxFOkZSRVE9WUVBUkxZO0lOVEVSVkFMPTE7QllEQVk9LTFTVTtCWU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