Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: email encoding should replace ALL allowed characters #4

Merged
merged 1 commit into from
Oct 22, 2022

Conversation

ferreiro
Copy link
Contributor

@ferreiro ferreiro commented Oct 22, 2022

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 [email protected] 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

  • Code is up-to-date with the main branch
  • npm run lint passes with this change
  • npm run test passes with this change
  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change
  • The new commits follow conventions outlined in the conventional commit spec

@ferreiro ferreiro changed the title fix(component): encode email should replace ALL allowed characters fix: email encoding should replace ALL allowed characters Oct 22, 2022
When running tests with the library in my app, I saw that if the user introduced an email with
spaces      [email protected]  the library was only replacin gthe first space and the rest were encoded
@ferreiro ferreiro merged commit 0e4f9b2 into main Oct 22, 2022
@ferreiro ferreiro deleted the ferreiro-fix-replace-all branch October 22, 2022 16:10
This was referenced Oct 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant