Skip to content

Commit 33c1954

Browse files
authored
Allow email addresses with trailing numbers in domain (#1642)
Domains such as .com09 are valid (see RFC1123)
1 parent 1eb0b42 commit 33c1954

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ const util = {
424424
if (!util.isString(data)) {
425425
return false;
426426
}
427-
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+([a-zA-Z]{2,}|xn--[a-zA-Z\-0-9]+)))$/;
427+
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+([a-zA-Z]{2,}[0-9]*|xn--[a-zA-Z\-0-9]+)))$/;
428428
return re.test(data);
429429
},
430430

test/general/key.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,6 +2367,19 @@ function versionSpecificTests() {
23672367
});
23682368
});
23692369

2370+
it('Generate key - single userID (special email format)', async function() {
2371+
const userID = { name: 'test', email: '[email protected]', comment: '' };
2372+
const opt = { userIDs: userID };
2373+
const { privateKey: armoredKey } = await openpgp.generateKey(opt);
2374+
// test also serialisation and parsing
2375+
const key = await openpgp.readKey({ armoredKey });
2376+
expect(key.users.length).to.equal(1);
2377+
expect(key.users[0].userID.userID).to.equal('test <[email protected]>');
2378+
expect(key.users[0].userID.name).to.equal(userID.name);
2379+
expect(key.users[0].userID.email).to.equal(userID.email);
2380+
expect(key.users[0].userID.comment).to.equal(userID.comment);
2381+
});
2382+
23702383
it('Generate key - setting date to the past', function() {
23712384
const past = new Date(0);
23722385
const opt = {

0 commit comments

Comments
 (0)