Skip to content

Commit

Permalink
fix(isFQDN): check more special chars (validatorjs#1799)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoPierro authored and theteladras committed Oct 30, 2021
1 parent b9c2968 commit f8d0de7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/isFQDN.js
Expand Up @@ -32,12 +32,12 @@ export default function isFQDN(str, options) {
return false;
}

if (!/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
if (!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
return false;
}

// disallow spaces && special characers
if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20\u00A9\uFFFD]/.test(tld)) {
// disallow spaces
if (/\s/.test(tld)) {
return false;
}
}
Expand Down
12 changes: 12 additions & 0 deletions test/validators.js
Expand Up @@ -1099,6 +1099,18 @@ describe('Validators', () => {
'domain.com/',
'/more.com',
'domain.com�',
'domain.co\u00A0m',
'domain.co\u1680m',
'domain.co\u2006m',
'domain.co\u2028m',
'domain.co\u2029m',
'domain.co\u202Fm',
'domain.co\u205Fm',
'domain.co\u3000m',
'domain.com\uDC00',
'domain.co\uEFFFm',
'domain.co\uFDDAm',
'domain.co\uFFF4m',
'domain.com©',
'example.0',
'192.168.0.9999',
Expand Down

0 comments on commit f8d0de7

Please sign in to comment.