0

I was really behind the times, and just recently converted my MySQL (v5.7.30) database tables to support utf8mb4 (emojis, symbols, etc). I'm using Devise 3.5.10 for user authentication in my Rails 4 app.

To validate email, I rely on Devise's default email_regexp.

Since emojis are permitted in email addresses, I want to make sure I get my validation right. The current regex I'm using lets them through, and when signing up with something like example@test.com, in the database it's actually saved as example@xn--test-r625f.com.

I logged out and logged back in with example@test.com, and sure enough it worked. So:

1) Should I continue using the default Devise email regex to allow symbols and emoji? /\A[^@\s]+@([^@\s]+\.)+[^@\W]+\z/

2) Why did it save in the database with the r625f text instead of the actual emoji? Elsewhere in my database where an emoji appears in a VARCHAR field I just see it as the actual emoji.

DelPiero
  • 489
  • 1
  • 10
  • 21
  • regex email validation is not worth too much thought after you determine it looks like `local-part@domain`, and the parts don't have spaces, so the devise regex is fine. – dbugger May 02 '20 at 01:45
  • @dbugger Ok sounds good. Do you know anything about emojis in email addresses saving as that strange encoding? – DelPiero May 04 '20 at 16:44
  • looks like devise is doing some serialization under the covers – dbugger May 04 '20 at 17:32

0 Answers0