validator.js icon indicating copy to clipboard operation
validator.js copied to clipboard

Fix(isEmail): Added support for internationalized domain names

Open aabboudi opened this issue 1 year ago • 4 comments

Added the allow_idn option which is passed down to isFQDN to check if the domain name contains non-ASCII characters. It defaults to true to maintain original behavior. If set to false, it rejects domain names in non-Latin alphabets like Arabic, Chinese, Cyrillic, etc.

Closes #2390

References

For more information on IDNs, please refer to the following:

Checklist

  • [x] PR contains only changes related; no stray files, etc.
  • [x] README updated (where applicable)
  • [x] Tests written (where applicable)
  • [x] References provided in PR (where applicable)

aabboudi avatar Oct 12 '24 14:10 aabboudi

Add tests too

rubiin avatar Oct 16 '24 07:10 rubiin

Went ahead and added tests for isEmail and isURL with the new option, allow_idn, set to false.

aabboudi avatar Oct 16 '24 22:10 aabboudi

Please update the README as well, see the checklist in the PR description

WikiRik avatar Oct 17 '24 19:10 WikiRik

Can we get this merged? AWS SES doesn't seem to support special characters in the domain, resulting in the error: "Domain contains control or whitespace". I believe this PR can also be combined with https://github.com/validatorjs/validator.js/pull/2049 as it doesn't allow invisible characters as well (when combined with allow_utf8_local_part), but they should be added to the test cases.

Apidcloud avatar Jun 23 '25 09:06 Apidcloud