Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions dev/Model/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]) + "')"
}
});
Expand Down
13 changes: 9 additions & 4 deletions dev/Screen/User/MailBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }]
];
}
}
9 changes: 9 additions & 0 deletions dev/View/User/MailBox/MessageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
</p>
<p>
<input type="text" id="snappymail-email" name="snappymail-email"
value="<?php echo $_['snappymail-email']; ?>" placeholder="<?php echo($l->t('Email')); ?>" />
value="<?php echo \htmlspecialchars($_['snappymail-email']); ?>" placeholder="<?php echo($l->t('Email')); ?>" />

<input type="password" id="snappymail-password" name="snappymail-password"
value="<?php echo $_['snappymail-password']; ?>" placeholder="<?php echo($l->t('Password')); ?>" />
value="<?php echo \htmlspecialchars($_['snappymail-password']); ?>" placeholder="<?php echo($l->t('Password')); ?>" />

<button id="snappymail-save-button" name="snappymail-save-button"><?php echo($l->t('Save')); ?></button>
&nbsp;&nbsp;<span class="snappymail-result-desc"></span>
Expand Down
2 changes: 1 addition & 1 deletion plugins/nextcloud/NextcloudContactsSuggestions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
69 changes: 66 additions & 3 deletions plugins/nextcloud/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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));
Expand Down
13 changes: 10 additions & 3 deletions snappymail/v/0.0.0/app/libraries/MailSo/Net/NetClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion vendors/squire2/dist/squire-raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down