Skip to content

Commit e7b3101

Browse files
fixup! fix: iMip reply from outlook.com does not contain organizer property
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
1 parent 7ea8ed9 commit e7b3101

File tree

2 files changed

+18
-36
lines changed

2 files changed

+18
-36
lines changed

apps/dav/lib/CalDAV/CalendarImpl.php

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,6 @@ public function handleIMipMessage(string $name, string $calendarData): void {
229229
} catch (ParseException $e) {
230230
throw new CalendarException('iMip message could not be processed because an error occurred while parsing the iMip message', 0, $e);
231231
}
232-
// Determine mode base on message source
233-
$mode = null;
234-
if (isset($vObject->PRODID)) {
235-
if ($vObject->PRODID->getValue() === 'Microsoft Exchange Server 2010') {
236-
$mode = 'EX2010';
237-
}
238-
}
239232
// validate the iMip message
240233
if (!isset($vObject->METHOD)) {
241234
throw new CalendarException('iMip message contains no valid method');
@@ -246,7 +239,7 @@ public function handleIMipMessage(string $name, string $calendarData): void {
246239
if (!isset($vObject->VEVENT->UID)) {
247240
throw new CalendarException('iMip message event dose not contain a UID');
248241
}
249-
if ($mode !== 'EX2010' && !isset($vObject->VEVENT->ORGANIZER)) {
242+
if (!isset($vObject->VEVENT->ORGANIZER)) {
250243
throw new CalendarException('iMip message event dose not contain an organizer');
251244
}
252245
if (!isset($vObject->VEVENT->ATTENDEE)) {
@@ -273,22 +266,15 @@ public function handleIMipMessage(string $name, string $calendarData): void {
273266
if (in_array($imipMethod, ['REPLY', 'REFRESH'], true)) {
274267
// extract sender (REPLY and REFRESH method should only have one attendee)
275268
$sender = strtolower($vObject->VEVENT->ATTENDEE->getValue());
276-
// fix Microsoft Exchange Server 2010 reply quirk
277-
if ($mode === 'EX2010' && $imipMethod === 'REPLY') {
278-
$recipient = $userAddress;
279-
}
280269
// extract and verify the recipient
281-
if ($mode === null) {
282-
$recipient = strtolower($vObject->VEVENT->ORGANIZER->getValue());
283-
284-
if (!in_array($recipient, $userAddresses, true)) {
285-
throw new CalendarException('iMip message dose not contain an organizer that matches the user');
286-
}
287-
// if the recipient address is not the same as the user address this means an alias was used
288-
// the iTip broker uses the users primary email address during processing
289-
if ($userAddress !== $recipient) {
290-
$recipient = $userAddress;
291-
}
270+
$recipient = strtolower($vObject->VEVENT->ORGANIZER->getValue());
271+
if (!in_array($recipient, $userAddresses, true)) {
272+
throw new CalendarException('iMip message dose not contain an organizer that matches the user');
273+
}
274+
// if the recipient address is not the same as the user address this means an alias was used
275+
// the iTip broker uses the users primary email address during processing
276+
if ($userAddress !== $recipient) {
277+
$recipient = $userAddress;
292278
}
293279
} elseif (in_array($imipMethod, ['PUBLISH', 'REQUEST', 'ADD', 'CANCEL'], true)) {
294280
// extract sender

lib/private/Calendar/Manager.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
use Throwable;
4040
use function array_map;
4141
use function array_merge;
42+
use function PHPUnit\Framework\isEmpty;
4243

4344
class Manager implements IManager {
4445
/**
@@ -252,15 +253,6 @@ public function handleIMip(
252253
$this->logger->warning('iMip message does not contain any event(s)');
253254
return false;
254255
}
255-
256-
$mode = null;
257-
if (isset($vObject->PRODID)) {
258-
if ($vObject->PRODID->getValue() === 'Microsoft Exchange Server 2010') {
259-
$mode = 'EX2010';
260-
$this->logger->warning('iMip message source is Microsoft Exchange Server 2010, using quirks mode');
261-
}
262-
}
263-
264256
/** @var VEvent $vEvent */
265257
$vEvent = $vObject->VEVENT;
266258

@@ -269,10 +261,14 @@ public function handleIMip(
269261
return false;
270262
}
271263

272-
// skip organizer check for message from Exchange 2010
273-
if ($mode !== 'EX2010' && !isset($vEvent->ORGANIZER)) {
274-
$this->logger->warning('iMip message event dose not contains an organizer');
275-
return false;
264+
if (!isset($vEvent->ORGANIZER)) {
265+
// quirks mode: for Microsoft Exchange Servers use recipient as organizer if no organizer is set
266+
if (isset($options['recipient']) && !isEmpty($options['recipient'])) {
267+
$vEvent->add('ORGANIZER', 'mailto:' . $options['recipient']);
268+
} else {
269+
$this->logger->warning('iMip message event dose not contains an organizer and no recipient was provided');
270+
return false;
271+
}
276272
}
277273

278274
if (!isset($vEvent->ATTENDEE)) {

0 commit comments

Comments
 (0)