Skip to content

Commit

Permalink
fix(isFQDN): check more special chars (#1799)
Browse files Browse the repository at this point in the history
fixes #1087
  • Loading branch information
MatteoPierro authored and profnandaa committed Oct 31, 2021
1 parent 002e7e6 commit 6a3684e
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 6a3684e

Please sign in to comment.