Skip to content

Commit

Permalink
Fixed: Incorrect Email Validation and Persistent display of error mes…
Browse files Browse the repository at this point in the history
…sage on message selection in MailExportForm RocketChat#32974
  • Loading branch information
Shahmaz0 committed Sep 23, 2024
1 parent c4fd29e commit bc0bf6a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ const MailExportForm = ({ formId, rid, onCancel, exportOptions }: MailExportForm
return undefined;
}

if (additionalEmails !== '' && validateEmail(additionalEmails)) {
if (additionalEmails !== '' && validateEmail(additionalEmails, {style: 'rfc'})) {
return undefined;
}

Expand Down
5 changes: 3 additions & 2 deletions apps/meteor/lib/emailValidator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export const validateEmail = (email: string, options: { style: string } = { style: 'basic' }): boolean => {
const basicEmailRegex = /^[^@]+@[^@]+$/;
const rfcEmailRegex =
/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;

const rfcEmailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;


switch (options.style) {
case 'rfc':
Expand Down

0 comments on commit bc0bf6a

Please sign in to comment.