email_inquire icon indicating copy to clipboard operation
email_inquire copied to clipboard

Changes the name validation regex to allow leading capital letters.

Open m-ashton opened this issue 1 year ago • 0 comments

The regex that validates the name part of the email address was built up by interpolating a regex expressing the character class of allowable name characters into another regex. This had some unusual consequences. The resulting name part regex looked like this:

/\A[a-z0-9][(?-mix:[a-z'0-9._&%+-])]{0,63}\z/x

This meant that only characters after the first character were matched case-insensitive. It also allowed a multiline match for characters after the first. This didn't seem intentional, and capital letters are perfectly fine in email addresses.

The fix is to express the allowed characters as a string and interpolate that string into the regex, and to make the entire regex case-insensitive.

The name regex also forbids non-alphanumeric leading characters in the name part. This seemed intentional, so this commit adds a spec to document that behavior.

m-ashton avatar Sep 01 '23 14:09 m-ashton