Email Validation doesn't accept some valid email addresses #385

Closed
opened 2026-04-24 07:55:01 -05:00 by mpldr · 1 comment
mpldr commented 2026-04-24 07:55:01 -05:00 (Migrated from github.com)

Describe the bug:

Some valid email addresses are not accepted by the system and instead show "Not a valid email".

To Reproduce:

Enter

  • ~@example.com
  • 敏萱@example.com

both of which are valid emails.

Expected behavior:

I can enter my email and use it to receive mails to.

Screenshots:

Image

Additional context:

This issue stems from zod's too restrictive Regex for email validation. Funnily enough, just a few lines higher, there is a comprehensive regex that would actually properly recognise these email addresses but it has been commented out for performance reasons and because it didn't support unicode. Validating an email on regex101 was sub 0.001 ms, which in my opinion doesn't qualify it to be a bottleneck. It also happens to recognise the chinese emails and most of its filters are unicode codepoints. The regex in question is:

// const emailRegex = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;

Granted, not exactly readable, but it's doubtful that this is a part that has to be updated regularly. Email adresses have been a rather stable format so far.

### Describe the bug: Some valid email addresses are not accepted by the system and instead show "Not a valid email". ### To Reproduce: Enter - `~@example.com` - `敏萱@example.com` both of which are valid emails. ### Expected behavior: I can enter my email and use it to receive mails to. ### Screenshots: <img width="800" height="258" alt="Image" src="https://github.com/user-attachments/assets/3e5cb84c-b702-40bd-9632-082a20181b96" /> ### Additional context: This issue stems from zod's too restrictive Regex for email validation. Funnily enough, just a few lines higher, there is a comprehensive regex that would actually properly recognise these email addresses but it has been commented out for performance reasons and because it didn't support unicode. Validating an email on regex101 was sub 0.001 ms, which in my opinion doesn't qualify it to be a bottleneck. It also happens to recognise the chinese emails and most of its filters are unicode codepoints. The regex in question is: ```js // const emailRegex = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i; ``` Granted, not exactly readable, but it's doubtful that this is a part that has to be updated regularly. Email adresses have been a rather stable format so far.
notquitenothing commented 2026-05-15 17:26:19 -05:00 (Migrated from github.com)

This should be fixed in the latest release v1.12.4

This should be fixed in the latest release [v1.12.4](https://github.com/voidauth/voidauth/releases/tag/v1.12.4)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
adam/gate#385
No description provided.