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]) + "')" } }); diff --git a/dev/Screen/User/MailBox.js b/dev/Screen/User/MailBox.js index 2725ece997..9d1c3ae29b 100644 --- a/dev/Screen/User/MailBox.js +++ b/dev/Screen/User/MailBox.js @@ -138,19 +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})? - [/^([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) + [/^([^/]+)\/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 }] ]; } } 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); 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')) { 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')); ?>" />    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); } 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)); 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; 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;