diff --git a/index.js b/index.js index 13e7907ef..493e6cbdf 100644 --- a/index.js +++ b/index.js @@ -157,6 +157,8 @@ var _isSlug = _interopRequireDefault(require("./lib/isSlug")); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var version = '11.1.0'; diff --git a/lib/isEmail.js b/lib/isEmail.js index 47f649d0f..ca756cc24 100644 --- a/lib/isEmail.js +++ b/lib/isEmail.js @@ -21,7 +21,7 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } -function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } +function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } diff --git a/lib/isFQDN.js b/lib/isFQDN.js index b5c769dba..965284f75 100644 --- a/lib/isFQDN.js +++ b/lib/isFQDN.js @@ -39,10 +39,10 @@ function isFQDN(str, options) { if (!parts.length || !/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) { return false; - } // disallow spaces + } // disallow spaces && special characers - if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20]/.test(tld)) { + if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20\u00A9\uFFFD]/.test(tld)) { return false; } } diff --git a/src/lib/isFQDN.js b/src/lib/isFQDN.js index c0dee981d..cb1b724f7 100644 --- a/src/lib/isFQDN.js +++ b/src/lib/isFQDN.js @@ -26,8 +26,8 @@ export default function isFQDN(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)) { + // disallow spaces && special characers + if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20\u00A9\uFFFD]/.test(tld)) { return false; } } diff --git a/test/validators.js b/test/validators.js index e86c36201..a01629dc3 100644 --- a/test/validators.js +++ b/test/validators.js @@ -113,6 +113,8 @@ describe('Validators', () => { 'multiple..dots@gmail.com', 'wrong()[]",:;<>@@gmail.com', '"wrong()[]",:;<>@@gmail.com', + 'username@domain.com�', + 'username@domain.com©', ], }); }); @@ -814,6 +816,8 @@ describe('Validators', () => { 's!ome.com', 'domain.com/', '/more.com', + 'domain.com�', + 'domain.com©', ], }); }); diff --git a/validator.js b/validator.js index defa7d437..e2af84a54 100644 --- a/validator.js +++ b/validator.js @@ -49,6 +49,10 @@ function _arrayWithHoles(arr) { } function _iterableToArrayLimit(arr, i) { + if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { + return; + } + var _arr = []; var _n = true; var _d = false; @@ -220,10 +224,10 @@ function isFQDN(str, options) { if (!parts.length || !/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) { return false; - } // disallow spaces + } // disallow spaces && special characers - if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20]/.test(tld)) { + if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20\u00A9\uFFFD]/.test(tld)) { return false; } }