diff --git a/src/util.js b/src/util.js index 8e9d42ee..89afff54 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); }, diff --git a/test/general/util.js b/test/general/util.js index 06d75bb6..b3b6a72d 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;