1
0
mirror of https://github.com/moparisthebest/mail synced 2024-12-21 23:08:50 -05:00

Fix invalid user id in PGP keys when realname is left empty

This commit is contained in:
Tankred Hase 2015-02-10 18:37:41 +01:00
parent 443cc3b59b
commit 5e246ee921
2 changed files with 12 additions and 4 deletions

View File

@ -28,8 +28,8 @@ PGP.prototype.generateKeys = function(options) {
}
// generate keypair
name = options.realname ? options.realname.replace(/[&\/\\#,+()$~%.'":*?<>{}]/g, '').trim() + ' ' : '';
userId = name + '<' + options.emailAddress + '>';
name = options.realname ? options.realname.replace(/[&\/\\#,+()$~%.'":*?<>{}]/g, '').trim() : '';
userId = name + ' <' + options.emailAddress + '>';
passphrase = (options.passphrase) ? options.passphrase : undefined;
resolve({

View File

@ -86,6 +86,10 @@ describe('PGP Crypto Api unit tests', function() {
publicKeyArmored: keys.publicKeyArmored
});
}).then(function() {
var keyParams = pgp.getKeyParams();
expect(keyParams.userIds[0].name).to.equal('');
expect(keyParams.userIds[0].emailAddress).to.equal(user);
return pgp.encrypt('secret', [keyObject.publicKeyArmored]);
}).then(function(ct) {
expect(ct).to.exist;
@ -117,7 +121,9 @@ describe('PGP Crypto Api unit tests', function() {
publicKeyArmored: keys.publicKeyArmored
});
}).then(function() {
expect(pgp.getKeyParams().userIds[0].name).to.equal('Jon Doe');
var keyParams = pgp.getKeyParams();
expect(keyParams.userIds[0].name).to.equal('Jon Doe');
expect(keyParams.userIds[0].emailAddress).to.equal(user);
return pgp.encrypt('secret', [keyObject.publicKeyArmored]);
}).then(function(ct) {
@ -150,7 +156,9 @@ describe('PGP Crypto Api unit tests', function() {
publicKeyArmored: keys.publicKeyArmored
});
}).then(function() {
expect(pgp.getKeyParams().userIds[0].name).to.equal('Jon Doe');
var keyParams = pgp.getKeyParams();
expect(keyParams.userIds[0].name).to.equal('Jon Doe');
expect(keyParams.userIds[0].emailAddress).to.equal(user);
return pgp.encrypt('secret', [keyObject.publicKeyArmored]);
}).then(function(ct) {