diff options
author | Christoph Wurst <ChristophWurst@users.noreply.github.com> | 2022-11-09 19:15:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-09 19:15:02 +0300 |
commit | adabe6ea0f8b772290943a7431211ed09571e70e (patch) | |
tree | 4e2de29ba2cb422ea17400bf2e82825c824ff80e | |
parent | 2ee8a768631238d346483f1956dca999bb19b038 (diff) | |
parent | 05e644538be258795b136809bbb9c6769040d671 (diff) |
Merge pull request #7540 from nextcloud/fix/hide-pgp-encryption-text
Fix envelope and message previews showing PGP ciphertext
-rw-r--r-- | src/components/Envelope.vue | 7 | ||||
-rw-r--r-- | src/components/ThreadEnvelope.vue | 24 | ||||
-rw-r--r-- | src/crypto/pgp.js | 4 | ||||
-rw-r--r-- | src/tests/unit/crypto/pgp.spec.js | 18 |
4 files changed, 42 insertions, 11 deletions
diff --git a/src/components/Envelope.vue b/src/components/Envelope.vue index 6163efad3..bc1b30cb3 100644 --- a/src/components/Envelope.vue +++ b/src/components/Envelope.vue @@ -65,7 +65,7 @@ </div> <div v-if="data.previewText" class="envelope__preview-text"> - {{ data.previewText }} + {{ isEncrypted ? t('mail', 'Encrypted message') : data.previewText }} </div> </template> <template #indicator> @@ -290,6 +290,7 @@ import EventModal from './EventModal' import EnvelopePrimaryActions from './EnvelopePrimaryActions' import { hiddenTags } from './tags.js' import { generateUrl } from '@nextcloud/router' +import { isPgpText } from '../crypto/pgp' import DownloadIcon from 'vue-material-design-icons/Download' export default { @@ -440,6 +441,10 @@ export default { showImportantIconVariant() { return this.data.flags.seen }, + isEncrypted() { + return this.data.previewText + && isPgpText(this.data.previewText) + }, isImportant() { return this.$store.getters .getEnvelopeTags(this.data.databaseId) diff --git a/src/components/ThreadEnvelope.vue b/src/components/ThreadEnvelope.vue index e12692708..983eb7e69 100644 --- a/src/components/ThreadEnvelope.vue +++ b/src/components/ThreadEnvelope.vue @@ -62,7 +62,7 @@ </div> <div v-if="showSubline" class="subline"> <span class="preview"> - {{ envelope.previewText }} + {{ isEncrypted ? t('mail', 'Encrypted message') : envelope.previewText }} </span> </div> <div v-for="tag in tags" @@ -179,6 +179,7 @@ import { hiddenTags } from './tags.js' import { showError } from '@nextcloud/dialogs' import { matchError } from '../errors/match' import NoTrashMailboxConfiguredError from '../errors/NoTrashMailboxConfiguredError' +import { isPgpText } from '../crypto/pgp' export default { name: 'ThreadEnvelope', @@ -263,6 +264,10 @@ export default { }, } }, + isEncrypted() { + return this.envelope.previewText + && isPgpText(this.envelope.previewText) + }, isImportant() { return this.$store.getters .getEnvelopeTags(this.envelope.databaseId) @@ -475,14 +480,6 @@ export default { } } } - .subline { - margin-left: 8px; - color: var(--color-text-maxcontrast); - cursor: default; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - } .envelope { display: flex; @@ -502,6 +499,15 @@ export default { margin-bottom: 10px; padding-bottom: 0; } + + .subline { + margin-left: 8px; + color: var(--color-text-maxcontrast); + cursor: default; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } } .envelope--header { diff --git a/src/crypto/pgp.js b/src/crypto/pgp.js index ef44a53de..36fce5653 100644 --- a/src/crypto/pgp.js +++ b/src/crypto/pgp.js @@ -26,3 +26,7 @@ */ export const isPgpgMessage = (message) => message.format === 'plain' && message.value.startsWith('-----BEGIN PGP MESSAGE-----') + +export function isPgpText(text) { + return text.startsWith('-----BEGIN PGP MESSAGE-----') +} diff --git a/src/tests/unit/crypto/pgp.spec.js b/src/tests/unit/crypto/pgp.spec.js index 26069dc0a..46d22fb25 100644 --- a/src/tests/unit/crypto/pgp.spec.js +++ b/src/tests/unit/crypto/pgp.spec.js @@ -19,7 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -import { isPgpgMessage } from '../../../crypto/pgp' +import { isPgpgMessage, isPgpText } from '../../../crypto/pgp' import { html, plain } from '../../../util/text' describe('pgp', () => { @@ -46,4 +46,20 @@ describe('pgp', () => { expect(isPgp).toEqual(true) }) + + it('detects non-pgp text', () => { + const text = 'Hi Alice' + + const isPgp = isPgpText(text) + + expect(isPgp).toEqual(false) + }) + + it('detects a pgp text', () => { + const message = '-----BEGIN PGP MESSAGE-----\nVersion: Mailvelope v4.3.1' + + const isPgp = isPgpText(message) + + expect(isPgp).toEqual(true) + }) }) |