diff --git a/src/js/dao/email-dao.js b/src/js/dao/email-dao.js index e694b78..3836814 100644 --- a/src/js/dao/email-dao.js +++ b/src/js/dao/email-dao.js @@ -490,6 +490,8 @@ define(function(require) { } function handleMessage(message, localCallback) { + message.subject = message.subject.split(str.subjectPrefix)[1]; + if (containsArmoredCiphertext(message)) { decrypt(message, localCallback); return; @@ -679,7 +681,7 @@ define(function(require) { // build encrypted text body email.body = greeting + message + ct + signature; - email.subject = email.subject; + email.subject = str.subjectPrefix + email.subject; } }; @@ -860,6 +862,7 @@ define(function(require) { mails.forEach(function(mail) { mail.body = str.cryptPrefix + mail.body.split(str.cryptPrefix)[1].split(str.cryptSuffix)[0] + str.cryptSuffix; + mail.subject = mail.subject.split(str.subjectPrefix)[1]; self._crypto.decrypt(mail.body, ownKeys.publicKeyArmored, function(err, decrypted) { mail.body = err ? err.errMsg : decrypted; after(); diff --git a/test/new-unit/email-dao-test.js b/test/new-unit/email-dao-test.js index 96bc5d8..d15adc2 100644 --- a/test/new-unit/email-dao-test.js +++ b/test/new-unit/email-dao-test.js @@ -54,7 +54,7 @@ define(function(require) { to: [{ address: 'qwe@qwe.de' }], - subject: '[whiteout] qweasd', + subject: 'qweasd', body: 'asd' }; nonWhitelistedMail = { @@ -592,7 +592,10 @@ define(function(require) { pgpStub.decrypt.withArgs(dummyEncryptedMail.body, mockKeyPair.publicKey).yields(null, dummyDecryptedMail.body); imapListStub = sinon.stub(dao, '_imapListMessages').withArgs({ folder: folder - }).yields(null, [dummyEncryptedMail]); + }).yields(null, [{ + uid: dummyEncryptedMail.uid, + subject: '[whiteout] ' + dummyEncryptedMail // the object has already been manipulated as a side-effect... + }]); dao.sync({ folder: folder