ZooTools / email-spell-checker

📮 An ultratiny (1.9 KB) and fast JavaScript email checker to reduce users typing a wrong email. Written in TypeScript. Enterprise-grade.
https://zootools.co/tools/email-spell-checker
MIT License
164 stars 11 forks source link

fix: email encoding should replace ALL allowed characters #4

Closed ferreiro closed 2 years ago

ferreiro commented 2 years ago

Bug description

This is a historical bug that mailcheck library (the one we're replacing) has had since the beginning.

mailcheck encoded the email to prevent XSS, but kept some characters unencoded to be compliant with RFC 5322. However, their function to replace characters only replaced the first character, since they forgot to run the spaces globally.

I noticed this while performing some tests of this library in our main application for ZooTools, an email with spaces like jorge@test.com was returned encoded

Screen Shot 2022-10-22 at 4 32 35 PM

![Uploading Screen Shot 2022-10-22 at 4.47.38 PM.png…]()

Description of change

I updated the regex to be run glob ally across every character. This will take a bit longer to validate the email, but it's blazing fast anyways and it's only run once when the email is being passed.

Pull-Request Checklist