From a5bff8674a31636c0cd6a42848290b6416e694d3 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Mon, 17 Oct 2022 09:33:28 +0200 Subject: [PATCH] Always show option to view as plain, by converting message HTML when plain is missing --- dev/Model/Message.js | 13 ++++++++----- .../app/templates/Views/User/MailMessageView.html | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/dev/Model/Message.js b/dev/Model/Message.js index c74e299d7..c56c6fcf0 100644 --- a/dev/Model/Message.js +++ b/dev/Model/Message.js @@ -4,7 +4,7 @@ import { MessagePriority } from 'Common/EnumsUser'; import { i18n } from 'Common/Translator'; import { doc, SettingsGet } from 'Common/Globals'; -import { encodeHtml, plainToHtml, cleanHtml } from 'Common/Html'; +import { encodeHtml, plainToHtml, htmlToPlain, cleanHtml } from 'Common/Html'; import { arrayLength, forEachObjectEntry } from 'Common/Utils'; import { serverRequestRaw, proxy } from 'Common/Links'; @@ -407,13 +407,16 @@ export class MessageModel extends AbstractModel { viewPlain() { const body = this.body; - if (body && this.plain()) { + if (body) { body.classList.toggle('html', 0); body.classList.toggle('plain', 1); body.innerHTML = plainToHtml( - this.plain() - .replace(/-----BEGIN PGP (SIGNED MESSAGE-----(\r?\n[a-z][^\r\n]+)+|SIGNATURE-----[\s\S]*)/, '') - .trim() + (this.plain() + ? this.plain() + .replace(/-----BEGIN PGP (SIGNED MESSAGE-----(\r?\n[a-z][^\r\n]+)+|SIGNATURE-----[\s\S]*)/, '') + .trim() + : htmlToPlain(body.innerHTML) + ) ); this.isHtml(false); this.hasImages(false); diff --git a/snappymail/v/0.0.0/app/templates/Views/User/MailMessageView.html b/snappymail/v/0.0.0/app/templates/Views/User/MailMessageView.html index d98604868..022f7d160 100644 --- a/snappymail/v/0.0.0/app/templates/Views/User/MailMessageView.html +++ b/snappymail/v/0.0.0/app/templates/Views/User/MailMessageView.html @@ -100,7 +100,7 @@
  • -
  • +