Skip to content

Commit

Permalink
#984: improved regex email validation
Browse files Browse the repository at this point in the history
  • Loading branch information
phjulia committed Aug 27, 2023
1 parent f691e6c commit 3023492
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ const Util = {
* @returns {boolean} first elem is type, second elem is subType
*/
emailValidator(email) {
const regex = new RegExp('[a-z0-9]+@[a-z]+.[a-z]{2,3}');
const regex = new RegExp(
"^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$"

Check failure

Code scanning / CodeQL

Inefficient regular expression High

This part of the regular expression may cause exponential backtracking on strings starting with '!a' and containing many repetitions of '!!'.

Check failure

Code scanning / CodeQL

Inefficient regular expression High

This part of the regular expression may cause exponential backtracking on strings starting with '!@0' and containing many repetitions of '0-0'.
);
return regex.test(email);
},

Expand Down

0 comments on commit 3023492

Please sign in to comment.