Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2022-11-07 13:01:35 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2022-11-07 17:05:30 +0300
commit05e644538be258795b136809bbb9c6769040d671 (patch)
tree93049adff9dd760a646ef8078dfa897e3482ebf1
parent7e2eb07bd3c5aa717b083447f8c20a48526a4ba6 (diff)
Fix envelope and message previews showing PGP ciphertext
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
-rw-r--r--src/components/Envelope.vue7
-rw-r--r--src/components/ThreadEnvelope.vue24
-rw-r--r--src/crypto/pgp.js4
-rw-r--r--src/tests/unit/crypto/pgp.spec.js18
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)
+ })
})