Skip to content

[BUG] mail.ParseAddress() and IsEmail regex disagree #430

@ns-dkoblas

Description

@ns-dkoblas

Description

The regex that is used to check email addresses does not support unicode local parts. RFC 6532 allows for unicode characters in the local part of the email address, which are not supported by this regex.

For example: Muñ[email protected]

	emailRegex = regexp.MustCompile("^[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])?)*$")

Steps to Reproduce

Attempt to validate any email address that has a unicode character in the local part.

Expected Behavior

I would expect that the behavior to be consistent between ParseAddress() and isEmail since they're doing the same thing.

Actual Behavior

Received error email: value must be a valid email address [string.email]

Screenshots/Logs

n/a

Environment

  • Operating System:
  • Version:
  • Compiler/Toolchain:
  • Protobuf Compiler & Version:
  • Protovalidate Version: v0.14.0

Possible Solution

isEmail() should use the builtin email validation.

Additional Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions