From 3673e21a770665db118a68e61cb5737851b5aed4 Mon Sep 17 00:00:00 2001 From: nauadratti Date: Thu, 30 Mar 2017 19:05:22 +0000 Subject: [PATCH 1/2] Allow punycode encoded TLDs in email Closes #500 --- src/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util.js b/src/util.js index 78394ad4..abf92927 100644 --- a/src/util.js +++ b/src/util.js @@ -43,7 +43,7 @@ export default { if (!this.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,}))$/; + 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]+)))$/; return re.test(data); }, From f56d5570361aabf610039cdff272764884cfbf9e Mon Sep 17 00:00:00 2001 From: nauadratti Date: Thu, 30 Mar 2017 19:29:50 +0000 Subject: [PATCH 2/2] Add a test for punycode encoded domains --- test/general/util.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/general/util.js b/test/general/util.js index d805eef1..614cad63 100644 --- a/test/general/util.js +++ b/test/general/util.js @@ -87,6 +87,10 @@ describe('Util unit tests', function() { var data = 'test@example.com'; expect(openpgp.util.isEmailAddress(data)).to.be.true; }); + it('should return true for valid email address', function() { + var data = 'test@xn--wgv.xn--q9jyb4c'; + expect(openpgp.util.isEmailAddress(data)).to.be.true; + }); it('should return false for invalid email address', function() { var data = 'Test User '; expect(openpgp.util.isEmailAddress(data)).to.be.false;