From 9a18d35fc28d26950c7c380f3f52212e9b322ca8 Mon Sep 17 00:00:00 2001 From: Landry Breuil Date: Sun, 30 Oct 2022 20:01:21 +0100 Subject: [PATCH 1/4] check that messageId/from/to are arrays before imploding/combining them --- modules/imap/hm-jmap.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/imap/hm-jmap.php b/modules/imap/hm-jmap.php index 614a2240a2..270b40d99e 100644 --- a/modules/imap/hm-jmap.php +++ b/modules/imap/hm-jmap.php @@ -833,8 +833,8 @@ private function normalize_headers($msg) { 'internal_date' => $msg['receivedAt'], 'size' => $msg['size'], 'date' => $msg['sentAt'], - 'from' => $this->combine_addresses($msg['from']), - 'to' => $this->combine_addresses($msg['to']), + 'from' => (is_array($msg['from']) ? $this->combine_addresses($msg['from']) : $msg['from']), + 'to' => (is_array($msg['to']) ? $this->combine_addresses($msg['to']) : $msg['to']), 'subject' => $msg['subject'], 'content-type' => '', 'timestamp' => strtotime($msg['receivedAt']), @@ -842,7 +842,7 @@ private function normalize_headers($msg) { 'x-priority' => '', 'type' => 'jmap', 'references' => '', - 'message_id' => implode(' ', $msg['messageId']), + 'message_id' => (is_array($msg['messageId']) ? implode(' ', $msg['messageId']) : ''), 'x_auto_bcc' => '' ); } From 9abb2245cbeb567941d273abadbf51f860fd2224 Mon Sep 17 00:00:00 2001 From: Landry Breuil Date: Sun, 30 Oct 2022 20:02:18 +0100 Subject: [PATCH 2/4] set api_url to the full url that was returned in apiUrl --- modules/imap/hm-jmap.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/imap/hm-jmap.php b/modules/imap/hm-jmap.php index 270b40d99e..6baeea8522 100644 --- a/modules/imap/hm-jmap.php +++ b/modules/imap/hm-jmap.php @@ -861,6 +861,7 @@ private function init_session($data, $url) { preg_replace("/\/$/", '', $url), $data['apiUrl'] ); + $this->api_url = $data['apiUrl']; $this->download_url = sprintf( '%s%s', preg_replace("/\/$/", '', $url), From f3811f09877b295782cbe2f85c1ed1617f9769b8 Mon Sep 17 00:00:00 2001 From: Landry Breuil Date: Sun, 30 Oct 2022 20:02:40 +0100 Subject: [PATCH 3/4] apparently jmap spec says that an account is primary in the 'primaryAccount' toplevel key so comment out checking isPrimary attr in account which doesnt exist --- modules/imap/hm-jmap.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/imap/hm-jmap.php b/modules/imap/hm-jmap.php index 6baeea8522..9621c1ce8b 100644 --- a/modules/imap/hm-jmap.php +++ b/modules/imap/hm-jmap.php @@ -873,10 +873,10 @@ private function init_session($data, $url) { $data['uploadUrl'] ); foreach ($data['accounts'] as $account) { - if (array_key_exists('isPrimary', $account) && $account['isPrimary']) { + //if (array_key_exists('isPrimary', $account) && $account['isPrimary']) { $this->account_id = array_keys($data['accounts'])[0]; - break; - } + // break; + //} } if ($this->account_id && count($this->folder_list) == 0) { $this->reset_folders(); From 15a5a463d3ba637a9c7996a9f6029cd50d1fa2da Mon Sep 17 00:00:00 2001 From: Landry Breuil Date: Sun, 30 Oct 2022 20:04:02 +0100 Subject: [PATCH 4/4] unescape slashes when encoding the JMAP methods --- modules/imap/hm-jmap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/imap/hm-jmap.php b/modules/imap/hm-jmap.php index 9621c1ce8b..0875951095 100644 --- a/modules/imap/hm-jmap.php +++ b/modules/imap/hm-jmap.php @@ -995,7 +995,7 @@ private function format_request($methods, $caps=array()) { return json_encode(array( 'using' => count($caps) == 0 ? $this->default_caps : $caps, 'methodCalls' => $methods - )); + ), JSON_UNESCAPED_SLASHES); } /**