mirror of
https://github.com/moparisthebest/mail
synced 2024-11-22 08:52:15 -05:00
Fix invalid user id in PGP keys when realname is left empty
This commit is contained in:
parent
443cc3b59b
commit
5e246ee921
@ -28,8 +28,8 @@ PGP.prototype.generateKeys = function(options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// generate keypair
|
// generate keypair
|
||||||
name = options.realname ? options.realname.replace(/[&\/\\#,+()$~%.'":*?<>{}]/g, '').trim() + ' ' : '';
|
name = options.realname ? options.realname.replace(/[&\/\\#,+()$~%.'":*?<>{}]/g, '').trim() : '';
|
||||||
userId = name + '<' + options.emailAddress + '>';
|
userId = name + ' <' + options.emailAddress + '>';
|
||||||
passphrase = (options.passphrase) ? options.passphrase : undefined;
|
passphrase = (options.passphrase) ? options.passphrase : undefined;
|
||||||
|
|
||||||
resolve({
|
resolve({
|
||||||
|
@ -86,6 +86,10 @@ describe('PGP Crypto Api unit tests', function() {
|
|||||||
publicKeyArmored: keys.publicKeyArmored
|
publicKeyArmored: keys.publicKeyArmored
|
||||||
});
|
});
|
||||||
}).then(function() {
|
}).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]);
|
return pgp.encrypt('secret', [keyObject.publicKeyArmored]);
|
||||||
}).then(function(ct) {
|
}).then(function(ct) {
|
||||||
expect(ct).to.exist;
|
expect(ct).to.exist;
|
||||||
@ -117,7 +121,9 @@ describe('PGP Crypto Api unit tests', function() {
|
|||||||
publicKeyArmored: keys.publicKeyArmored
|
publicKeyArmored: keys.publicKeyArmored
|
||||||
});
|
});
|
||||||
}).then(function() {
|
}).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]);
|
return pgp.encrypt('secret', [keyObject.publicKeyArmored]);
|
||||||
}).then(function(ct) {
|
}).then(function(ct) {
|
||||||
@ -150,7 +156,9 @@ describe('PGP Crypto Api unit tests', function() {
|
|||||||
publicKeyArmored: keys.publicKeyArmored
|
publicKeyArmored: keys.publicKeyArmored
|
||||||
});
|
});
|
||||||
}).then(function() {
|
}).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]);
|
return pgp.encrypt('secret', [keyObject.publicKeyArmored]);
|
||||||
}).then(function(ct) {
|
}).then(function(ct) {
|
||||||
|
Loading…
Reference in New Issue
Block a user