This project is archived and is in readonly mode.

#648 ✓committed
Marc-André Lafortune

mail_to :javascript should use decodeURIComponent instead unescape

Reported by Marc-André Lafortune | July 17th, 2008 @ 10:45 PM | in 2.x

If the 'name' parameter for mail_to contains unicode characters, these will not show properly in the link. Solution involves using to_json before outputing each byte.

Example:

mail_to "xxx@example.com", "Écris-nous", :encode=>:javascript

The link's label will show as "Écris-nous".

Solution:

Modify mail_to's code:

-   "document.write('#{content_tag("a", name || email_address, html_options.merge({ "href" => "mailto:"+email_address+extras }))}');".each_byte do |c|
+   "document.write('#{content_tag("a", (name || email_address).to_json[1..-2], html_options.merge({ "href" => "mailto:"+email_address+extras }))}');".each_byte do |c|

Temporary solution for affected users: call to_json yourself, as in:

mail_to "xxx@example.com", "Écris-nous", :encode=>:javascript

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Pages