Merge pull request #537 from nauadratti/patch-1
Allow punycode encoded TLDs in email
This commit is contained in:
commit
aa476b4905
|
@ -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);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user