diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-09-04 15:20:07 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-09-04 15:20:07 -0700 |
commit | 21ffef38a5dc5a6a21f7e841aecab5b51f4fd185 (patch) | |
tree | 6969623dd32333b99e2631d15ef93ad75091339c /actionview | |
parent | e25fdad2f147e6f368958f9a06a5ac9d10288408 (diff) | |
download | rails-21ffef38a5dc5a6a21f7e841aecab5b51f4fd185.tar.gz rails-21ffef38a5dc5a6a21f7e841aecab5b51f4fd185.tar.bz2 rails-21ffef38a5dc5a6a21f7e841aecab5b51f4fd185.zip |
use path escaping for email addresses
Due to e25fdad2f147e6f368958f9a06a5ac9d10288408, we are correctly using
path escaping for email addresses. This commit fixes the tests to
expect path escaping.
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/lib/action_view/helpers/url_helper.rb | 2 | ||||
-rw-r--r-- | actionview/test/template/url_helper_test.rb | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/actionview/lib/action_view/helpers/url_helper.rb b/actionview/lib/action_view/helpers/url_helper.rb index d676a0a931..477d676e21 100644 --- a/actionview/lib/action_view/helpers/url_helper.rb +++ b/actionview/lib/action_view/helpers/url_helper.rb @@ -468,7 +468,7 @@ module ActionView }.compact extras = extras.empty? ? '' : '?' + extras.join('&') - encoded_email_address = ERB::Util.url_encode(email_address).gsub("%40", "@") + encoded_email_address = Rack::Utils.escape_path(email_address) html_options["href"] = "mailto:#{encoded_email_address}#{extras}" content_tag("a".freeze, name || email_address, html_options, &block) diff --git a/actionview/test/template/url_helper_test.rb b/actionview/test/template/url_helper_test.rb index 027b72b354..2bd3098217 100644 --- a/actionview/test/template/url_helper_test.rb +++ b/actionview/test/template/url_helper_test.rb @@ -501,14 +501,14 @@ class UrlHelperTest < ActiveSupport::TestCase def test_mail_to_with_special_characters assert_dom_equal( - %{<a href="mailto:%23%21%24%25%26%27%2A%2B-%2F%3D%3F%5E_%60%7B%7D%7C%7E@example.org">#!$%&'*+-/=?^_`{}|~@example.org</a>}, + %(<a href="mailto:%23!$%25&'*+-/=?%5E_%60%7B%7D%7C~@example.org">#!$%&'*+-/=?^_`{}|~@example.org</a>), mail_to("#!$%&'*+-/=?^_`{}|~@example.org") ) end def test_mail_with_options assert_dom_equal( - %{<a href="mailto:me@example.com?cc=ccaddress%40example.com&bcc=bccaddress%40example.com&body=This%20is%20the%20body%20of%20the%20message.&subject=This%20is%20an%20example%20email&reply-to=foo%40bar.com">My email</a>}, + %{<a href="mailto:me@example.com?cc=ccaddress@example.com&bcc=bccaddress@example.com&body=This%20is%20the%20body%20of%20the%20message.&subject=This%20is%20an%20example%20email&reply-to=foo@bar.com">My email</a>}, mail_to("me@example.com", "My email", cc: "ccaddress@example.com", bcc: "bccaddress@example.com", subject: "This is an example email", body: "This is the body of the message.", reply_to: "foo@bar.com") ) @@ -533,7 +533,7 @@ class UrlHelperTest < ActiveSupport::TestCase end def test_mail_to_with_block_and_options - assert_dom_equal %{<a class="special" href="mailto:me@example.com?cc=ccaddress%40example.com"><span>Email me</span></a>}, + assert_dom_equal %{<a class="special" href="mailto:me@example.com?cc=ccaddress@example.com"><span>Email me</span></a>}, mail_to('me@example.com', cc: "ccaddress@example.com", class: "special") { content_tag(:span, 'Email me') } end |