1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-25 18:32:20 -05:00

fix signature verfication by formatting newlines before encryption

This commit is contained in:
Tankred Hase 2013-12-05 18:30:10 +01:00
parent 497d5eb4f9
commit 3700e211ec
2 changed files with 9 additions and 2 deletions

View File

@ -159,6 +159,9 @@ define(function(require) {
receiverKeys[i] = openpgp.read_publicKey(receiverKeys[i])[0];
}
// format: \n -> \r\n
plaintext = plaintext.replace(/\r\n/g, '\n').replace(/[\t ]+\n/g, "\n").replace(/\n/g, '\r\n');
// encrypt and sign the plaintext
try {
ct = openpgp.write_signed_and_encrypted_message(privateKey, receiverKeys, plaintext);

View File

@ -118,7 +118,11 @@ define(function(require) {
});
describe('Encryption', function() {
var message = 'Hello, World!';
var message = 'asdfs\n\nThursday, Nov 21, 2013 7:38 PM asdf@example.com wrote:\n' +
'> asdf\n' +
'> \n' +
'> Thursday, Nov 21, 2013 7:32 PM asdf@example.com wrote:\n' +
'> > secret 3';
beforeEach(function(done) {
pgp.importKeys({
@ -195,7 +199,7 @@ define(function(require) {
it('should work', function(done) {
pgp.decrypt(ciphertext, pubkey, function(err, pt) {
expect(err).to.not.exist;
expect(pt).to.equal(message);
expect(pt).to.equal(message.replace(/\r\n/g, '\n').replace(/[\t ]+\n/g, "\n").replace(/\n/g, '\r\n'));
done();
});
});