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

Disallow spaces for a TLD part #677

Merged
merged 7 commits into from
Jun 29, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/isFQDN.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ function isFDQN(str, options) {
if (!parts.length || !/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
return false;
}
// disallow spaces
if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20]/.test(tld)) {
return false;
}
}
for (var part, i = 0; i < parts.length; i++) {
part = parts[i];
Expand Down
4 changes: 4 additions & 0 deletions src/lib/isFQDN.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export default function isFDQN(str, options) {
if (!parts.length || !/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
return false;
}
// disallow spaces
if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20]/.test(tld)) {
return false;
}
}
for (let part, i = 0; i < parts.length; i++) {
part = parts[i];
Expand Down
14 changes: 14 additions & 0 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,19 @@ describe('Validators', function () {
'gmailgmailgmailgmailgmail@gmail.com',
`${repeat('a', 64)}@${repeat('a', 251)}.com`,
`${repeat('a', 65)}@${repeat('a', 250)}.com`,
'[email protected] m',
'[email protected] m',
'[email protected] m',
'[email protected] m',
'[email protected] m',
'[email protected] m',
'[email protected] m',
'[email protected] m',
'[email protected] m',
'[email protected] m',
'[email protected] m',
'[email protected] m',
'[email protected] m',
],
});
});
Expand Down Expand Up @@ -101,6 +114,7 @@ describe('Validators', function () {
'somename@gmail.com',
'hans.m端[email protected]',
'[email protected]',
'tü[email protected]',
],
});
});
Expand Down
4 changes: 4 additions & 0 deletions validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ function isFDQN(str, options) {
if (!parts.length || !/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
return false;
}
// disallow spaces
if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20]/.test(tld)) {
return false;
}
}
for (var part, i = 0; i < parts.length; i++) {
part = parts[i];
Expand Down
Loading