Merge pull request #537 from nauadratti/patch-1

Allow punycode encoded TLDs in email
This commit is contained in:
Bart Butler 2018-02-07 23:26:18 -08:00 committed by GitHub
commit aa476b4905
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -43,7 +43,7 @@ export default {
if (!this.isString(data)) { if (!this.isString(data)) {
return false; 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); return re.test(data);
}, },

View File

@ -87,6 +87,10 @@ describe('Util unit tests', function() {
var data = 'test@example.com'; var data = 'test@example.com';
expect(openpgp.util.isEmailAddress(data)).to.be.true; 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() { it('should return false for invalid email address', function() {
var data = 'Test User <test@example.com>'; var data = 'Test User <test@example.com>';
expect(openpgp.util.isEmailAddress(data)).to.be.false; expect(openpgp.util.isEmailAddress(data)).to.be.false;