Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check more special characters when validating a FQDN #1799

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/lib/isFQDN.js
Expand Up @@ -25,12 +25,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 @@ -1074,6 +1074,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