Skip to content

Commit

Permalink
Reduce max address length in isEmail, closes #655
Browse files Browse the repository at this point in the history
  • Loading branch information
chriso committed Jun 22, 2017
1 parent 812bf04 commit 8f2b0ac
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
([#660](https://github.com/chriso/validator.js/pull/660))
- Fixed a bug in credit card validation
([#670](https://github.com/chriso/validator.js/pull/670))
- Reduced the maximum allowed address in `isEmail()` based on
[RFC3696 errata](http://www.rfc-editor.org/errata_search.php?rfc=3696&eid=1690)
([#655](https://github.com/chriso/validator.js/issues/655))
- New locales
([#647](https://github.com/chriso/validator.js/pull/647),
[#667](https://github.com/chriso/validator.js/pull/667),
Expand Down
2 changes: 1 addition & 1 deletion lib/isEmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function isEmail(str, options) {
user = user.replace(/\./g, '').toLowerCase();
}

if (!(0, _isByteLength2.default)(user, { max: 64 }) || !(0, _isByteLength2.default)(domain, { max: 256 })) {
if (!(0, _isByteLength2.default)(user, { max: 64 }) || !(0, _isByteLength2.default)(domain, { max: 254 })) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/isEmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function isEmail(str, options) {
}

if (!isByteLength(user, { max: 64 }) ||
!isByteLength(domain, { max: 256 })) {
!isByteLength(domain, { max: 254 })) {
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('Validators', function () {
'"foobar"@example.com',
'" foo m端ller "@example.com',
'"foo\\@bar"@example.com',
`${repeat('a', 64)}@${repeat('a', 252)}.com`,
`${repeat('a', 64)}@${repeat('a', 250)}.com`,
],
invalid: [
'invalidemail@',
Expand All @@ -69,8 +69,8 @@ describe('Validators', function () {
'[email protected].',
'[email protected]',
'gmailgmailgmailgmailgmail@gmail.com',
`${repeat('a', 64)}@${repeat('a', 253)}.com`,
`${repeat('a', 65)}@${repeat('a', 252)}.com`,
`${repeat('a', 64)}@${repeat('a', 251)}.com`,
`${repeat('a', 65)}@${repeat('a', 250)}.com`,
],
});
});
Expand Down
2 changes: 1 addition & 1 deletion validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
user = user.replace(/\./g, '').toLowerCase();
}

if (!isByteLength(user, { max: 64 }) || !isByteLength(domain, { max: 256 })) {
if (!isByteLength(user, { max: 64 }) || !isByteLength(domain, { max: 254 })) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion validator.min.js

Large diffs are not rendered by default.

0 comments on commit 8f2b0ac

Please sign in to comment.