rails/rails — pull request #7305 by iblue (2012-08-09 22:20:44+00:00)
Title: Do not escape HTML entities in text files

Rails escapes HTML entities in erb files. This is great, because it prevents Cross Site Scripting and other evil attacks. However there is one case, where this behavior leads to undesired effects.

Rails escapes HTML entities in plain text mails. When I am using a `message.text.erb` file, `ActionMailer` correctly detects that the mail contains plain text and sets a `text/plain` mime type. However, ERB still handles this as an html file and escapes HTML entities.

For example, if my template contains `Dear <%= @customer_name %>, ...` and `@customer_name` is *Foobar & Partner*, then the mail will contain *Dear Foobar &amp; Partner*.

The following commit just disables HTML escaping in text templates. A text erb template is every file that has `.text` in the file name and is handled by erb.