Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow email addresses with trailing numbers in domain #1642

Merged
merged 1 commit into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ const util = {
if (!util.isString(data)) {
return false;
}
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]+)))$/;
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]+)))$/;
return re.test(data);
},

Expand Down
13 changes: 13 additions & 0 deletions test/general/key.js
Original file line number Diff line number Diff line change
Expand Up @@ -2273,6 +2273,19 @@ function versionSpecificTests() {
});
});

it('Generate key - single userID (special email format)', async function() {
const userID = { name: 'test', email: 'test1@com.com09', comment: '' };
const opt = { userIDs: userID };
const { privateKey: armoredKey } = await openpgp.generateKey(opt);
// test also serialisation and parsing
const key = await openpgp.readKey({ armoredKey });
expect(key.users.length).to.equal(1);
expect(key.users[0].userID.userID).to.equal('test <test1@com.com09>');
expect(key.users[0].userID.name).to.equal(userID.name);
expect(key.users[0].userID.email).to.equal(userID.email);
expect(key.users[0].userID.comment).to.equal(userID.comment);
});

it('Generate key - setting date to the past', function() {
const past = new Date(0);
const opt = {
Expand Down