heartcombo / devise

Flexible authentication solution for Rails with Warden.
http://blog.plataformatec.com.br/tag/devise/
MIT License
24k stars 5.55k forks source link

Non english characters on email templates cause escaping #2086

Closed victormartins closed 12 years ago

victormartins commented 12 years ago

When using non english characters on the confirmation email, like "Olá" the email gets escaped and the token seems to get invalid. Someone posted this problem like a year ago: http://stackoverflow.com/questions/4793504/rails-3-and-devise-escaping-mailer-templates Is solution is ok, but is there a way to prevent devise to escape the characters?

josevalim commented 12 years ago

This is weird and I have written templates in portuguese and I haven't seen it before. It makes me think it is not a Devise issue, but a Rails one. If you put those characters in any other template, not necessarily a Devise one, does the issue still happen?

victormartins commented 12 years ago

Sorry, for the delay, I went on vacation :)

I've done the tutorial from rails casts 206 and sent emails with and without latin chars, in text and html without any escaping.

With Devise If I write the word Olá, I get the email get's like this: http://pastie.org/5064730 This must be something simple to solve, I just can't seem to find the issue :(

Using Rails 3.2.8 And Ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-linux] on Heroku

josevalim commented 12 years ago

What is the template name? Can you provide an app that reproduces the error?

José Valim www.plataformatec.com.br Founder and Lead Developer

victormartins commented 12 years ago

The templates are: confirmation_instructions.html.erb reset_password_instructions.html.erb unlock_instructions.html.erb

When I get home I will try to do an app with the problem.

Thanks :)

victormartins commented 12 years ago

Here it is a simple test: https://github.com/victormartins/DeviseTest

As you can see in with the last commit, just adding "Olá" breaks the email by sending the url escaped like so: http://pastie.org/5069701

Without the Olá, everything looks fine: http://pastie.org/5069703

What do you think?

Thanks for looking at this José :)

josevalim commented 12 years ago

Hey @victormartins, before I give it a shot, would you mind adding a mailer template to the same app but without using Devise that works just fine as you said previously? Thanks!

victormartins commented 12 years ago

Hello,

Well now I'm completed lost, this really seems a rails configuration issue. I've added the mailer on a different computer, and in this example the email sent with my mailer template gets like this: http://pastie.org/5072842

I've noticed that now those templates have: Content-Transfer-Encoding: base64

While Devise gets: Content-Transfer-Encoding: quoted-printable

I don't know what I did different at home to send the email email with the latim characters, because in both situations I just followed Ryan Bates tutorial.

If you want to give it a try do rake db:seed and enter with user@user.com 999999

Then on the top of the page click " Say Hello" and in the console you will see the mailer sending the email.

josevalim commented 12 years ago

How do they look like when you access them in your gmail? The same? Or the characters are gone too?

victormartins commented 12 years ago

Brrr shame on me :-1: .... just tested it on my heroku app and on gmail it looks fine. I think that at the time I was trying to copy paste the confirmation urls from the console while testing and they sudently broke after changing the template.They probably worked on a real email reader all along.

Sorry for wasting your time :(