When trying to add an email address with an apostrophe / single quote (') in the local part (before the @), it fails validation.
I know I can just edit src/applications/people/storage/PhabricatorUserEmail.php, as mentioned in T12359, but I was hoping that since you added "!" to the list of acceptable characters in D8320, that you could also include an apostrophe.
This should do the trick:
$email_regex = "(^[a-z0-9_+.!'-]+@[a-z0-9_+:.-]+$)i";
https://en.wikipedia.org/wiki/Email_address#Local-part indicates that an apostrophe is an acceptable character (3rd bullet point).
To include all of them, and also to escape the "-", in case someone ever moves its position and doesn't notice that they've potentially introduced a bug:
$email_regex = "(^[a-z0-9.!#$%&'*+/=?\^_`{|}~\-]+@[a-z0-9_+:.\-]+$)i";
This passes all current tests (i.e. all addresses meant to pass, do, and likewise for all that are meant to fail).
To reproduce:
- Set up a new account, or add an email to an existing profile.
- Enter an otherwise valid email address, but insert an apostrophe before the @.
Expected result:
- Email is considered valid; account is created or email is added to existing profile.
Observed result:
- An error indicating the email address provided is invalid (though no mention of the reason).