feat: validate email according to RFC 5322 (#22540)

This commit is contained in:
NeatGuyCoding
2025-07-17 14:20:44 +08:00
committed by GitHub
parent 4b2baeea65
commit fafb1d5fd7

View File

@@ -113,8 +113,8 @@ const EmailChangeModal = ({ onClose, email, show }: Props) => {
}
const isValidEmail = (email: string): boolean => {
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
return emailRegex.test(email)
const rfc5322emailRegex = /^[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])?)*$/
return rfc5322emailRegex.test(email) && email.length <= 254
}
const checkNewEmailExisted = async (email: string) => {