From d7ec0854a9823208dbac27286f0c3c144b14abd7 Mon Sep 17 00:00:00 2001 From: Torben Dannhauer Date: Sat, 26 Jul 2025 17:51:50 +0200 Subject: [PATCH] Update Driver.php Handles access to Collections properties more defensive as they are optional according Protocol (..stated the internet... ;) ) --- lib/Horde/Core/ActiveSync/Driver.php | 30 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/Horde/Core/ActiveSync/Driver.php b/lib/Horde/Core/ActiveSync/Driver.php index 3df64551..94246efb 100644 --- a/lib/Horde/Core/ActiveSync/Driver.php +++ b/lib/Horde/Core/ActiveSync/Driver.php @@ -1408,8 +1408,8 @@ public function getMessage($folderid, $id, array $collection) $message = $this->_connector->calendar_export($id, [ 'protocolversion' => $this->_version, 'truncation' => empty($collection['truncation']) ? Horde_ActiveSync::TRUNCATION_9 : $collection['truncation'], - 'bodyprefs' => $collection['bodyprefs'], - 'mimesupport' => $collection['mimesupport']], $folder_id); + 'bodyprefs' => !empty($collection['bodyprefs']) ? $collection['bodyprefs'] : [], + 'mimesupport' => !empty($collection['mimesupport']) ? $collection['mimesupport'] : 0], $folder_id); // Nokia MfE requires the optional UID element. if (!$message->getUid()) { @@ -1459,8 +1459,8 @@ public function getMessage($folderid, $id, array $collection) $message = $this->_connector->contacts_export($id, [ 'protocolversion' => $this->_version, 'truncation' => empty($collection['truncation']) ? Horde_ActiveSync::TRUNCATION_9 : $collection['truncation'], - 'bodyprefs' => $collection['bodyprefs'], - 'mimesupport' => $collection['mimesupport'], + 'bodyprefs' => !empty($collection['bodyprefs']) ? $collection['bodyprefs'] : [], + 'mimesupport' => !empty($collection['mimesupport']) ? $collection['mimesupport'] : 0, 'device' => $this->_device]); } catch (Horde_Exception_NotFound $e) { $this->_logger->err($e->getMessage()); @@ -1477,9 +1477,9 @@ public function getMessage($folderid, $id, array $collection) try { $message = $this->_connector->tasks_export($id, [ 'protocolversion' => $this->_version, - 'truncation' => $collection['truncation'], - 'bodyprefs' => $collection['bodyprefs'], - 'mimesupport' => $collection['mimesupport']]); + 'truncation' => empty($collection['truncation']) ? Horde_ActiveSync::TRUNCATION_9 : $collection['truncation'], + 'bodyprefs' => !empty($collection['bodyprefs']) ? $collection['bodyprefs'] : [], + 'mimesupport' => !empty($collection['mimesupport']) ? $collection['mimesupport'] : 0]); } catch (Horde_Exception_NotFound $e) { $this->_logger->err($e->getMessage()); $this->_endBuffer(); @@ -1495,9 +1495,9 @@ public function getMessage($folderid, $id, array $collection) try { $message = $this->_connector->notes_export($id, [ 'protocolversion' => $this->_version, - 'truncation' => $collection['truncation'], - 'bodyprefs' => $collection['bodyprefs'], - 'mimesupport' => $collection['mimesupport']]); + 'truncation' => empty($collection['truncation']) ? Horde_ActiveSync::TRUNCATION_9 : $collection['truncation'], + 'bodyprefs' => !empty($collection['bodyprefs']) ? $collection['bodyprefs'] : [], + 'mimesupport' => !empty($collection['mimesupport']) ? $collection['mimesupport'] : 0]); } catch (Horde_Exception_NotFound $e) { $this->_logger->err($e->getMessage()); $this->_endBuffer(); @@ -1520,11 +1520,11 @@ public function getMessage($folderid, $id, array $collection) 'truncation' => !empty($collection['truncation']) ? $collection['truncation'] : (!empty($collection['mimetruncation']) ? $collection['mimetruncation'] : false), - 'bodyprefs' => $collection['bodyprefs'], + 'bodyprefs' => !empty($collection['bodyprefs']) ? $collection['bodyprefs'] : [], 'bodypartprefs' => !empty($collection['bodypartprefs']) ? $collection['bodypartprefs'] : false, - 'mimesupport' => $collection['mimesupport'], + 'mimesupport' => !empty($collection['mimesupport']) ? $collection['mimesupport'] : 0, ] ); } catch (Horde_ActiveSync_Exception $e) { @@ -1532,12 +1532,12 @@ public function getMessage($folderid, $id, array $collection) $context = 'Protocol Version: ' . $this->_version . "\r\n" . 'Truncation: ' . (!empty($collection['truncation']) ? $collection['truncation'] - : (!empty($collection['mimetruncation']) ? $collection['mimetruncation'] : 'false')). "\r\n" - . 'BodyPrefs: ' . print_r($collection['bodyprefs'], true) . "\r\n" + : (!empty($collection['mimetruncation']) ? $collection['mimetruncation'] : 'false')) . "\r\n" + . 'BodyPrefs: ' . print_r(!empty($collection['bodyprefs']) ? $collection['bodyprefs'] : [], true) . "\r\n" . 'BodyPartPrefs: ' . (!empty($collection['bodypartprefs']) ? print_r($collection['bodypartprefs'], true) : 'false') . "\r\n" - . 'MimeSupport: ' . $collection['mimesupport']; + . 'MimeSupport: ' . (!empty($collection['mimesupport']) ? $collection['mimesupport'] : 0); $this->_logger->err($context);