From c5c8698fb7ef8c4d8f52a452ddc6ef4037c7d3cf Mon Sep 17 00:00:00 2001
From: jeanmichel
Date: Thu, 19 Nov 2026 14:48:54 +1100
Subject: [PATCH 01/10] Nextcloud: escape the email and password in the
personal settings form
templates/personal_settings.php printed the saved SnappyMail email and password into
value="..." unescaped, so a value with a quote could break out of the attribute and
inject markup into the Nextcloud settings page.
---
.../nextcloud/snappymail/templates/personal_settings.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/integrations/nextcloud/snappymail/templates/personal_settings.php b/integrations/nextcloud/snappymail/templates/personal_settings.php
index 93a86c7444..1de0ad03d6 100644
--- a/integrations/nextcloud/snappymail/templates/personal_settings.php
+++ b/integrations/nextcloud/snappymail/templates/personal_settings.php
@@ -8,10 +8,10 @@
+ value="" placeholder="t('Email')); ?>" />
+ value="" placeholder="t('Password')); ?>" />
From de38117f25f6927739227dd3f828f0707d8a7bef Mon Sep 17 00:00:00 2001
From: jeanmichel
Date: Thu, 19 Nov 2026 14:48:55 +1100
Subject: [PATCH 02/10] Nextcloud 34: get the app manager through the container
\OC::$server->getAppManager() no longer exists on Nextcloud 34 (the old \OC::$server
getters were removed), so the oidc_login check in SnappyMailHelper failed. Use
\OC::$server->get(\OCP\App\IAppManager::class).
---
integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php b/integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php
index cb1893d724..1d48e90f09 100644
--- a/integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php
+++ b/integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php
@@ -269,7 +269,7 @@ public static function isOIDCLogin(): bool
{
if (static::getAppConfigValue('snappymail-autologin-oidc', false)) {
// Check if the OIDC Login app is enabled
- if (\OC::$server->getAppManager()->isEnabledForUser('oidc_login')) {
+ if (\OC::$server->get(\OCP\App\IAppManager::class)->isEnabledForUser('oidc_login')) {
// Check if session is an OIDC Login
$ocSession = static::getSession();
if ($ocSession->get('is_oidc')) {
From 64891083bdbb711850a7eb889be0b4d5678db8f6 Mon Sep 17 00:00:00 2001
From: jeanmichel
Date: Tue, 17 Nov 2026 23:18:46 +1100
Subject: [PATCH 03/10] nextcloud: Nextcloud files work again
(\OCP\Files::getStorage() was removed)
Nextcloud 34's \OCP\Files only has rmdirr(), so "Attach from Nextcloud",
"Save .eml to Nextcloud" and "Save attachments to Nextcloud" failed. The
plugin now uses the user folder (IRootFolder::getUserFolder()) through a
small adapter with the old storage methods; older Nextcloud keeps
getStorage().
---
plugins/nextcloud/index.php | 69 +++++++++++++++++++++++++++++++++++--
1 file changed, 66 insertions(+), 3 deletions(-)
diff --git a/plugins/nextcloud/index.php b/plugins/nextcloud/index.php
index a56f4efa26..c4b2eb947f 100644
--- a/plugins/nextcloud/index.php
+++ b/plugins/nextcloud/index.php
@@ -117,7 +117,7 @@ public function NextcloudAttachFile() : array
'tempName' => ''
];
$sFile = $this->jsonParam('file', '');
- $oFiles = \OCP\Files::getStorage('files');
+ $oFiles = static::userFiles();
if ($oFiles && $oFiles->is_file($sFile) && $fp = $oFiles->fopen($sFile, 'rb')) {
$oActions = \RainLoop\Api::Actions();
$oAccount = $oActions->getAccountFromToken();
@@ -154,7 +154,7 @@ public function NextcloudSaveMsg() : array
}
$sSaveFolder = $sSaveFolder ?: 'Emails';
- $oFiles = \OCP\Files::getStorage('files');
+ $oFiles = static::userFiles();
if ($oFiles) {
$oFiles->is_dir($sSaveFolder) || $oFiles->mkdir($sSaveFolder);
}
@@ -182,7 +182,7 @@ function ($rResource) use ($oFiles, $aResult) {
public function DoAttachmentsActions(\SnappyMail\AttachmentsAction $data)
{
if (static::isLoggedIn() && 'nextcloud' === $data->action) {
- $oFiles = \OCP\Files::getStorage('files');
+ $oFiles = static::userFiles();
if ($oFiles && \method_exists($oFiles, 'file_put_contents')) {
$sSaveFolder = \ltrim($this->jsonParam('NcFolder', ''), '/');
$sSaveFolder = $sSaveFolder ?: 'Attachments';
@@ -387,6 +387,69 @@ protected function configMapping() : array
);
}
+ /**
+ * The user's Nextcloud files, with the old storage methods this plugin uses.
+ * \OCP\Files::getStorage() was removed from Nextcloud (34 only has rmdirr()), which broke
+ * "Attach from Nextcloud", "Save .eml to Nextcloud" and "Save attachments to Nextcloud".
+ * Newer Nextcloud: the same calls on the user folder (IRootFolder::getUserFolder()).
+ */
+ private static function userFiles() : ?object
+ {
+ if (\method_exists(\OCP\Files::class, 'getStorage')) {
+ return \OCP\Files::getStorage('files');
+ }
+ $sUID = SnappyMailHelper::getUID();
+ if (!$sUID) {
+ return null;
+ }
+ $oFolder = \OCP\Server::get(\OCP\Files\IRootFolder::class)->getUserFolder($sUID);
+ return new class($oFolder) {
+ public function __construct(private \OCP\Files\Folder $folder) {}
+ private function node(string $path) : ?\OCP\Files\Node
+ {
+ $path = \ltrim($path, '/');
+ return $this->folder->nodeExists($path) ? $this->folder->get($path) : null;
+ }
+ public function file_exists(string $path) : bool
+ {
+ return null !== $this->node($path);
+ }
+ public function is_file(string $path) : bool
+ {
+ return $this->node($path) instanceof \OCP\Files\File;
+ }
+ public function is_dir(string $path) : bool
+ {
+ return $this->node($path) instanceof \OCP\Files\Folder;
+ }
+ public function mkdir(string $path) : bool
+ {
+ $this->folder->newFolder(\ltrim($path, '/'));
+ return true;
+ }
+ /** @return resource|false */
+ public function fopen(string $path, string $mode)
+ {
+ $node = $this->node($path);
+ return $node instanceof \OCP\Files\File ? $node->fopen($mode) : false;
+ }
+ /** @param string|resource $data */
+ public function file_put_contents(string $path, $data) : bool
+ {
+ try {
+ $node = $this->node($path);
+ $node instanceof \OCP\Files\File
+ ? $node->putContent($data)
+ : $this->folder->newFile(\ltrim($path, '/'), $data);
+ return true;
+ } catch (\Throwable $e) {
+ \SnappyMail\Log::warning('Nextcloud', $e->getMessage());
+ return false;
+ }
+ }
+ };
+ }
+
private static function SmartFileExists(string $sFilePath, $oFiles) : string
{
$sFilePath = \str_replace('\\', '/', \trim($sFilePath));
From fd5b72ada78c8bfde07d6a11cddfaea0676d1b1b Mon Sep 17 00:00:00 2001
From: jeanmichel
Date: Thu, 19 Nov 2026 14:48:55 +1100
Subject: [PATCH 04/10] Nextcloud contacts suggestions: catch Throwable, not
only Exception
A PHP Error during the contacts lookup (e.g. a removed Nextcloud API) escaped the
catch and broke the suggestions request instead of returning no suggestions.
---
plugins/nextcloud/NextcloudContactsSuggestions.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/nextcloud/NextcloudContactsSuggestions.php b/plugins/nextcloud/NextcloudContactsSuggestions.php
index 80bd6d88d9..98bd0e3861 100644
--- a/plugins/nextcloud/NextcloudContactsSuggestions.php
+++ b/plugins/nextcloud/NextcloudContactsSuggestions.php
@@ -74,7 +74,7 @@ public function Process(\RainLoop\Model\Account $oAccount, string $sQuery, int $
return \array_slice(\array_values($aResult), 0, $iInputLimit);
}
}
- catch (\Exception $oException)
+ catch (\Throwable $oException)
{
$this->logException($oException);
}
From 773445eafc6b1e865d8a8381d98d5ed38810f73a Mon Sep 17 00:00:00 2001
From: jeanmichel
Date: Thu, 19 Nov 2026 14:48:55 +1100
Subject: [PATCH 05/10] squire2: treat INPUT and IFRAME as inline, as upstream
Squire does
Squire's selection bookmarks are elements. Without INPUT in inlineNodeNames
the first and last selected lines become "containers", so making a list, quote or
indent from a selection skipped those lines. Same list as squire-rte 2.3.2.
---
vendors/squire2/dist/squire-raw.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/vendors/squire2/dist/squire-raw.js b/vendors/squire2/dist/squire-raw.js
index db6ec7dc97..dd233f72c0 100644
--- a/vendors/squire2/dist/squire-raw.js
+++ b/vendors/squire2/dist/squire-raw.js
@@ -59,7 +59,7 @@
var notWS = /[^ \t\r\n\u200B]/;
// source/node/Category.ts
- var inlineNodeNames = /^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|EL|FN)|EM|FONT|HR|I(?:MG|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:AMP|MALL|PAN|TR(?:IKE|ONG)|U[BP])?|TIME|U|VAR|WBR)$/;
+ var inlineNodeNames = /^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|EL|FN)|EM|FONT|HR|I(?:FRAME|MG|NPUT|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:AMP|MALL|PAN|TR(?:IKE|ONG)|U[BP])?|TIME|U|VAR|WBR)$/;
var leafNodeNames = /* @__PURE__ */ new Set(["BR", "HR", "IMG"]);
var UNKNOWN = 0;
var INLINE = 1;
From 0d782f82314326b9fb6d71842e4f28329abda3a6 Mon Sep 17 00:00:00 2001
From: jeanmichel
Date: Thu, 19 Nov 2026 14:48:55 +1100
Subject: [PATCH 06/10] Show images: leave cid: alone and check each CSS
background's own url
- The style url() loop tested src, the leftover variable of the loop above (the
last image's src, or undefined), instead of the url it is about to set, so a
background was loaded or skipped depending on an unrelated image.
- cid: urls are inline attachments kept in data-x-src for Compose, not external
images, so Show images no longer turns them into (proxied) external requests.
---
dev/Model/Message.js | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/dev/Model/Message.js b/dev/Model/Message.js
index 356924eca0..61df514dba 100644
--- a/dev/Model/Message.js
+++ b/dev/Model/Message.js
@@ -581,15 +581,17 @@ export class MessageModel extends AbstractModel {
src, useProxy = !!SettingsGet('proxyExternalImages');
body.querySelectorAll('img[' + attr + ']').forEach(node => {
src = node.getAttribute(attr);
- if (isValid(src)) {
+ // cid: is kept in data-x-src for Compose, it is not an external image
+ if (!src.startsWith('cid:') && isValid(src)) {
node.src = useProxy ? proxy(src) : src;
}
});
body.querySelectorAll('[data-x-style-url]').forEach(node => {
JSON.parse(node.dataset.xStyleUrl).forEach(data => {
- // cid: is kept in data-x-src for Compose, it is not an external image
- if (!src.startsWith('cid:') && isValid(src)) {
+ // cid: is an inline attachment, not an external image
+ // (check this url, not the leftover src of the img loop above, which may be undefined)
+ if (!data[1].startsWith('cid:') && isValid(data[1])) {
node.style[data[0]] = "url('" + (useProxy ? proxy(data[1]) : data[1]) + "')"
}
});
From 83ee1b768928e7f968f25ae7af8a68d61b79a205 Mon Sep 17 00:00:00 2001
From: jeanmichel
Date: Thu, 19 Nov 2026 14:48:56 +1100
Subject: [PATCH 07/10] NetClient: reconnect when asked to connect to a
different server or user
Connect() while a socket was open only logged SocketAlreadyConnectedException and kept
the old connection, even when the new settings point at another host, port, type or
username (e.g. switching accounts in one request). Only the same connection is kept now;
otherwise the old one is closed first.
---
.../v/0.0.0/app/libraries/MailSo/Net/NetClient.php | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Net/NetClient.php b/snappymail/v/0.0.0/app/libraries/MailSo/Net/NetClient.php
index a4a19472e4..8358906f14 100644
--- a/snappymail/v/0.0.0/app/libraries/MailSo/Net/NetClient.php
+++ b/snappymail/v/0.0.0/app/libraries/MailSo/Net/NetClient.php
@@ -84,9 +84,16 @@ public function Connect(ConnectSettings $oSettings) : void
}
if ($this->IsConnected()) {
- $this->writeLogException(new Exceptions\SocketAlreadyConnectedException, \LOG_ERR, false);
-// $this->Disconnect();
- return;
+ $sameConnection = $this->Settings
+ && $this->Settings->host === $oSettings->host
+ && $this->Settings->port === $oSettings->port
+ && $this->Settings->type === $oSettings->type
+ && $this->Settings->username === $oSettings->username;
+ if ($sameConnection) {
+ $this->writeLogException(new Exceptions\SocketAlreadyConnectedException, \LOG_ERR, false);
+ return;
+ }
+ $this->Disconnect();
}
$this->Settings = $oSettings;
From e6877c73472ce42a5c96e290327552baa6615008 Mon Sep 17 00:00:00 2001
From: jeanmichel
Date: Thu, 19 Nov 2026 14:48:56 +1100
Subject: [PATCH 08/10] Message view: clicking the reading pane gives it
keyboard focus
With the preview pane on, a click in the open message left the keyboard scope on the
message list, so arrow keys, PageUp/PageDown and Space moved the list selection instead
of scrolling the message. MessageList already does the reverse for its own pane.
---
dev/View/User/MailBox/MessageView.js | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/dev/View/User/MailBox/MessageView.js b/dev/View/User/MailBox/MessageView.js
index 90d597d45a..9c2c0a9378 100644
--- a/dev/View/User/MailBox/MessageView.js
+++ b/dev/View/User/MailBox/MessageView.js
@@ -383,6 +383,15 @@ export class MailMessageView extends AbstractViewRight {
onBuild(dom) {
const eqs = (ev, s) => ev.target.closestWithin(s, dom);
dom.addEventListener('click', event => {
+ // A click in the reading pane gives it the keyboard, so arrow keys, PageUp/Down
+ // and Space scroll the message instead of moving the message list selection.
+ // (MessageList does the reverse when its own pane is clicked.)
+ if (currentMessage() && SettingsUserStore.usePreviewPane()
+ && ScopeMessageView !== AppUserStore.focusedState()
+ && eqs(event, '.messageView')) {
+ AppUserStore.focusedState(ScopeMessageView);
+ }
+
let el = eqs(event, 'a');
if (el && 0 === event.button && mailToHelper(el.href)) {
stopEvent(event);
From 0cd408762b4ad1adfeca2fd734276dd2e2c9da18 Mon Sep 17 00:00:00 2001
From: jeanmichel
Date: Thu, 19 Nov 2026 15:03:10 +1100
Subject: [PATCH 09/10] Bugfix: a message opened from search results or a later
page reloaded page 1 without the search
The Message route pattern had one optional group for "/p{page}/{search}", but its
normalize_ read the page from that group and the search from a fourth group that does not
exist. So every message link with a search or page > 1 routed to page 1 with an empty
search: onRoute() saw the search change, reloaded the list, and the clicked message did
not open. Page and search are now separate groups, and the search is decoded like the
Search route does.
---
dev/Screen/User/MailBox.js | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dev/Screen/User/MailBox.js b/dev/Screen/User/MailBox.js
index 2725ece997..51e675e731 100644
--- a/dev/Screen/User/MailBox.js
+++ b/dev/Screen/User/MailBox.js
@@ -146,8 +146,10 @@ export class MailBoxUserScreen extends AbstractScreen {
[folder(request, vals), 1, decodeURI(pString(vals[1]))]
}],
// Message: {folder}/m{uid}(/p{int})?(/{search})?
- [/^([a-zA-Z0-9.~_-]+)\/m([1-9][0-9]*)(?:\/(.+))?$/, { normalize_: (request, vals) =>
- [folder(request, vals), pInt(vals[2]), pString(vals[3]), pInt(vals[1])]
+ // (page and search are separate groups: a message opened from a search result or a later
+ // page must keep them, or onRoute() reloads page 1 without the search)
+ [/^([a-zA-Z0-9.~_-]+)\/m([1-9][0-9]*)(?:\/p([1-9][0-9]*))?(?:\/(.+))?$/, { normalize_: (request, vals) =>
+ [folder(request, vals), pInt(vals[2], 1), decodeURI(pString(vals[3])), pInt(vals[1])]
}],
// Page: {folder}/p{int}(/{search})?
[/^([a-zA-Z0-9.~_-]+)\/p([1-9][0-9]*)(?:\/(.+))?$/, { normalize_: fNormS }]
From 6a1d9cb64984ef63b2a157abef8f1af1948e3e2c Mon Sep 17 00:00:00 2001
From: jeanmichel
Date: Thu, 19 Nov 2026 15:05:20 +1100
Subject: [PATCH 10/10] Bugfix: no message, page or search links in folders
with spaces or accents in their name
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
fullNameHash only encodes # ~ / and hasher decodes the hash before routing, so a folder
such as "Business Development", "Équipe" or "R&D (old)" reaches the router with those
characters. The Search, Message and Page routes only accepted [a-zA-Z0-9.~_-] in the
folder part, so in such folders clicking a message, paging or searching matched no route
and did nothing (opening the folder itself worked through the Folder route). The folder
part now accepts anything but "/", like the Folder route.
---
dev/Screen/User/MailBox.js | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/dev/Screen/User/MailBox.js b/dev/Screen/User/MailBox.js
index 51e675e731..9d1c3ae29b 100644
--- a/dev/Screen/User/MailBox.js
+++ b/dev/Screen/User/MailBox.js
@@ -138,21 +138,24 @@ export class MailBoxUserScreen extends AbstractScreen {
folder = (request, vals) => request ? pString(vals[0]) : getFolderInboxName(),
fNormS = (request, vals) => [folder(request, vals), request ? pInt(vals[1]) : 1, decodeURI(pString(vals[2]))];
+ // {folder} is a fullNameHash: only # ~ / are encoded in it (FolderCollection.js), and hasher
+ // decodes the hash before routing, so it can hold spaces, accents, & ( ) ' etc. Anything
+ // but "/" is accepted, as in the Folder route, or such folders had no message/page/search link.
return [
// Folder: INBOX | INBOX.sub | Sent | fullNameHash
[/^([^/]*)$/, { normalize_: fNormS }],
// Search: {folder}/{string}
- [/^([a-zA-Z0-9.~_-]+)\/(.+)\/?$/, { normalize_: (request, vals) =>
+ [/^([^/]+)\/(.+)\/?$/, { normalize_: (request, vals) =>
[folder(request, vals), 1, decodeURI(pString(vals[1]))]
}],
// Message: {folder}/m{uid}(/p{int})?(/{search})?
// (page and search are separate groups: a message opened from a search result or a later
// page must keep them, or onRoute() reloads page 1 without the search)
- [/^([a-zA-Z0-9.~_-]+)\/m([1-9][0-9]*)(?:\/p([1-9][0-9]*))?(?:\/(.+))?$/, { normalize_: (request, vals) =>
+ [/^([^/]+)\/m([1-9][0-9]*)(?:\/p([1-9][0-9]*))?(?:\/(.+))?$/, { normalize_: (request, vals) =>
[folder(request, vals), pInt(vals[2], 1), decodeURI(pString(vals[3])), pInt(vals[1])]
}],
// Page: {folder}/p{int}(/{search})?
- [/^([a-zA-Z0-9.~_-]+)\/p([1-9][0-9]*)(?:\/(.+))?$/, { normalize_: fNormS }]
+ [/^([^/]+)\/p([1-9][0-9]*)(?:\/(.+))?$/, { normalize_: fNormS }]
];
}
}