Skip to content

Commit

Permalink
fixed issue #2432
Browse files Browse the repository at this point in the history
  • Loading branch information
code0emperor committed Aug 9, 2024
1 parent 1f159ea commit 7975293
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions src/lib/isEmail.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import assertString from './util/assertString';
import assertString from './util/assertString.js';

Check failure on line 1 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Unexpected use of file extension "js" for "./util/assertString.js"

Check failure on line 1 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Unexpected use of file extension "js" for "./util/assertString.js"

Check failure on line 1 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Unexpected use of file extension "js" for "./util/assertString.js"

Check failure on line 1 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Unexpected use of file extension "js" for "./util/assertString.js"

Check failure on line 1 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Unexpected use of file extension "js" for "./util/assertString.js"

Check failure on line 1 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Unexpected use of file extension "js" for "./util/assertString.js"

Check failure on line 1 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Unexpected use of file extension "js" for "./util/assertString.js"

import isByteLength from './isByteLength';
import isFQDN from './isFQDN';
import isIP from './isIP';
import merge from './util/merge';
import isByteLength from './isByteLength.js';

Check failure on line 3 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Unexpected use of file extension "js" for "./isByteLength.js"

Check failure on line 3 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Unexpected use of file extension "js" for "./isByteLength.js"

Check failure on line 3 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Unexpected use of file extension "js" for "./isByteLength.js"

Check failure on line 3 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Unexpected use of file extension "js" for "./isByteLength.js"

Check failure on line 3 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Unexpected use of file extension "js" for "./isByteLength.js"

Check failure on line 3 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Unexpected use of file extension "js" for "./isByteLength.js"

Check failure on line 3 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Unexpected use of file extension "js" for "./isByteLength.js"
import isFQDN from './isFQDN.js';

Check failure on line 4 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Unexpected use of file extension "js" for "./isFQDN.js"

Check failure on line 4 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Unexpected use of file extension "js" for "./isFQDN.js"

Check failure on line 4 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Unexpected use of file extension "js" for "./isFQDN.js"

Check failure on line 4 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Unexpected use of file extension "js" for "./isFQDN.js"

Check failure on line 4 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Unexpected use of file extension "js" for "./isFQDN.js"

Check failure on line 4 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Unexpected use of file extension "js" for "./isFQDN.js"

Check failure on line 4 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Unexpected use of file extension "js" for "./isFQDN.js"
import isIP from './isIP.js';

Check failure on line 5 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Unexpected use of file extension "js" for "./isIP.js"

Check failure on line 5 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Unexpected use of file extension "js" for "./isIP.js"

Check failure on line 5 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Unexpected use of file extension "js" for "./isIP.js"

Check failure on line 5 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Unexpected use of file extension "js" for "./isIP.js"

Check failure on line 5 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Unexpected use of file extension "js" for "./isIP.js"

Check failure on line 5 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Unexpected use of file extension "js" for "./isIP.js"

Check failure on line 5 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Unexpected use of file extension "js" for "./isIP.js"
import merge from './util/merge.js';

Check failure on line 6 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Unexpected use of file extension "js" for "./util/merge.js"

Check failure on line 6 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Unexpected use of file extension "js" for "./util/merge.js"

Check failure on line 6 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Unexpected use of file extension "js" for "./util/merge.js"

Check failure on line 6 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Unexpected use of file extension "js" for "./util/merge.js"

Check failure on line 6 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Unexpected use of file extension "js" for "./util/merge.js"

Check failure on line 6 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Unexpected use of file extension "js" for "./util/merge.js"

Check failure on line 6 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Unexpected use of file extension "js" for "./util/merge.js"

const default_email_options = {
allow_display_name: false,
Expand Down Expand Up @@ -106,40 +106,40 @@ export default function isEmail(str, options) {
}

let user = parts.join('@');

Check failure on line 109 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Trailing spaces not allowed

Check failure on line 109 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Trailing spaces not allowed

Check failure on line 109 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Trailing spaces not allowed

Check failure on line 109 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Trailing spaces not allowed

Check failure on line 109 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Trailing spaces not allowed

Check failure on line 109 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Trailing spaces not allowed

Check failure on line 109 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Trailing spaces not allowed
if (options.domain_specific_validation && (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com')) {
/*
Previously we removed dots for gmail addresses before validating.
This was removed because it allows `multiple..dots@gmail.com`
to be reported as valid, but it is not.
Gmail only normalizes single dots, removing them from here is pointless,
should be done in normalizeEmail
Previously we removed dots for gmail addresses before validating.
This was removed because it allows `multiple..dots@gmail.com`
to be reported as valid, but it is not.
Gmail only normalizes single dots, removing them from here is pointless,
should be done in normalizeEmail
*/
user = user.toLowerCase();

// Removing sub-address from username before gmail validation
const username = user.split('+')[0];

// Dots are not included in gmail length restriction
if (!isByteLength(username.replace(/\./g, ''), { min: 6, max: 30 })) {
return false;
user = user.toLowerCase();

Check failure on line 118 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Expected indentation of 4 spaces but found 3

Check failure on line 118 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Expected indentation of 4 spaces but found 3

Check failure on line 118 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Expected indentation of 4 spaces but found 3

Check failure on line 118 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Expected indentation of 4 spaces but found 3

Check failure on line 118 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Expected indentation of 4 spaces but found 3

Check failure on line 118 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Expected indentation of 4 spaces but found 3

Check failure on line 118 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Expected indentation of 4 spaces but found 3

Check failure on line 119 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Trailing spaces not allowed

Check failure on line 119 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Trailing spaces not allowed

Check failure on line 119 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Trailing spaces not allowed

Check failure on line 119 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Trailing spaces not allowed

Check failure on line 119 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Trailing spaces not allowed

Check failure on line 119 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Trailing spaces not allowed

Check failure on line 119 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Trailing spaces not allowed
// Removing sub-address from username before gmail validation

Check failure on line 120 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Expected indentation of 4 spaces but found 3

Check failure on line 120 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Expected indentation of 4 spaces but found 3

Check failure on line 120 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Expected indentation of 4 spaces but found 3

Check failure on line 120 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Expected indentation of 4 spaces but found 3

Check failure on line 120 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Expected indentation of 4 spaces but found 3

Check failure on line 120 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Expected indentation of 4 spaces but found 3

Check failure on line 120 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Expected indentation of 4 spaces but found 3
const username = user.split('+')[0];

Check failure on line 121 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Expected indentation of 4 spaces but found 3

Check failure on line 121 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Expected indentation of 4 spaces but found 3

Check failure on line 121 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Expected indentation of 4 spaces but found 3

Check failure on line 121 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Expected indentation of 4 spaces but found 3

Check failure on line 121 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Expected indentation of 4 spaces but found 3

Check failure on line 121 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Expected indentation of 4 spaces but found 3

Check failure on line 121 in src/lib/isEmail.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Expected indentation of 4 spaces but found 3
// Dots are not included in gmail length restriction
if (!isByteLength(username.replace(/\./g, ''), { min: 6, max: 30 })) {
return false;
}

const user_parts = username.split('.');
for (let i = 0; i < user_parts.length; i++) {
if (!gmailUserPart.test(user_parts[i])) {
return false;
}
}
}

if (options.ignore_max_length === false && (
!isByteLength(user, { max: 64 }) ||
!isByteLength(domain, { max: 254 }))
) {
return false;
}

if (!isFQDN(domain, {
require_tld: options.require_tld,
ignore_max_length: options.ignore_max_length,
Expand All @@ -148,29 +148,29 @@ export default function isEmail(str, options) {
if (!options.allow_ip_domain) {
return false;
}

if (!isIP(domain)) {
if (!domain.startsWith('[') || !domain.endsWith(']')) {
return false;
}

let noBracketdomain = domain.slice(1, -1);

if (noBracketdomain.length === 0 || !isIP(noBracketdomain)) {
return false;
}
}
}

if (options.blacklisted_chars) {
if (user.search(new RegExp(`[${options.blacklisted_chars}]+`, 'g')) !== -1) return false;
}

if (user[0] === '"') {
if (user[0] === '"' && user[user.length - 1] === '"') {
user = user.slice(1, user.length - 1);
return options.allow_utf8_local_part ?
quotedEmailUserUtf8.test(user) :
quotedEmailUser.test(user);
quotedEmailUserUtf8.test(user) :
quotedEmailUser.test(user);
}

const pattern = options.allow_utf8_local_part ?
Expand Down

0 comments on commit 7975293

Please sign in to comment.