zod icon indicating copy to clipboard operation
zod copied to clipboard

Bugfix: Commas are incorrectly allowed in email regex.

Open mokemoko opened this issue 1 year ago • 1 comments

In #2824, email regex changed, but it seems inadvertently allowed , which were previously not permitted in email.

Email regex before #2824

/^([A-Z0-9_+-]+\.?)*[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;

Email regex after #2824

/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;

For the latter part [A-Z0-9_+-\.], it probably wanted to add only . to [A-Z0-9_+-]. But, the addition of . after the unescaped hyphen has caused it to be interpreted as a range from + to .. Therefore, , contained between + and . is now permitted.

So, fix this issue with escaping hyphens simply.

mokemoko avatar Feb 29 '24 14:02 mokemoko

Deploy Preview for guileless-rolypoly-866f8a ready!

Name Link
Latest commit 40e72f9eaf576985f876d1afc2dbc22f73abc1ba
Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/661f05dd2509bd0008bbcaef
Deploy Preview https://deploy-preview-3286--guileless-rolypoly-866f8a.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Feb 29 '24 14:02 netlify[bot]

Thank you! Fantastic PR, apologies for the delay on such a no-brainer PR. That accidental range issue could have been a lot worse lol.

colinhacks avatar Apr 16 '24 23:04 colinhacks

This has landed in Zod 3.23.

https://github.com/colinhacks/zod/releases/tag/v3.23.0

colinhacks avatar Apr 21 '24 22:04 colinhacks