Skip to content

Commit

Permalink
fix(isEmail) do not allow non-breaking space in user part (#2237)
Browse files Browse the repository at this point in the history
Co-authored-by: jpoole <jpoole@maxmind.com>

fixes #2218
  • Loading branch information
jeremy21212121 committed Jun 26, 2023
1 parent 4f63909 commit 63b1e4d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/isEmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const splitNameAddress = /^([^\x00-\x1F\x7F-\x9F\cX]+)</i;
const emailUserPart = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i;
const gmailUserPart = /^[a-z\d]+$/;
const quotedEmailUser = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i;
const emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i;
const emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A1-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i;
const quotedEmailUserUtf8 = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i;
const defaultMaxEmailLength = 254;
/* eslint-enable max-len */
Expand Down
4 changes: 4 additions & 0 deletions test/validators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ describe('Validators', () => {
'"wrong()[]",:;<>@@gmail.com',
'username@domain.com�',
'username@domain.com©',
'nbsp test@test.com',
'nbsp_test@te st.com',
'nbsp_test@test.co m',
],
});
});
Expand Down Expand Up @@ -117,6 +120,7 @@ describe('Validators', () => {
'hans.m端ller@test.com',
'z@co.c',
'tüst@invalid.com',
'nbsp test@test.com',
],
});
});
Expand Down

0 comments on commit 63b1e4d

Please sign in to comment.