bikeindex/bike_index

Consider adding minimal validation of email addresses

Closed this issue · 3 comments

When we attempt to send an email to a malformed destination email address, we get the following:
https://app.honeybadger.io/projects/35931/faults?sort=last_seen_desc&q=RCPT+TO+syntax+error+

Sometimes this occurs to what appears to be user error (e.g., "name.gmail.com" or "namegmail.com" instead of "name@gmail.com").

We may want to consider adding some minimal client-facing validation for emails.

We do have some minimal client side validation of emails - but only on account signup, I believe. It probably makes sense to do other places

We might have some lingering bad data in that case. Testing signup now, I'm not seeing any user-facing validation errors (although the signup process is halted)

User.where("email NOT LIKE '%@%'").pluck(:email).sample(5)
# => ["cowles", "greenup", "elizabethshiao.gmail.com", "0715440600", "\"><img src=\"x\" onerror=\"alert(1)\"/>"]

User.where("email NOT LIKE '%@%'").count
# => 162

demo

Ahhh. We have mailcheck - which corrects common misspellings. And is also unmaintained (and is also made by @derrickko, heyo buddy!). So we get this:

Screen Shot 2019-08-06 at 10 00 21 AM

Which is evidently not enough. Related to #325 and #134