From 2553bd785c0b41193257851ac0267515ec3c9dc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 17 Jun 2013 10:01:03 -0700 Subject: Merge pull request #10971 from dtaniwaki/escape_link_to_unless Always escape the result of link_to_unless method --- actionpack/lib/action_view/helpers/url_helper.rb | 2 +- actionpack/test/template/url_helper_test.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index 812bb4de9e..51c3100dff 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -422,7 +422,7 @@ module ActionView if block_given? block.arity <= 1 ? capture(name, &block) : capture(name, options, html_options, &block) else - name + ERB::Util.html_escape(name) end else link_to(name, options, html_options) diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 38f77203e0..a00d71ff29 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -306,6 +306,11 @@ class UrlHelperTest < ActiveSupport::TestCase link_to_unless(true, "Showing", url_hash) { "test" } + + assert_equal %{<b>Showing</b>}, link_to_unless(true, "Showing", url_hash) + assert_equal %{<b>Showing</b>}, link_to_unless(false, "Showing", url_hash) + assert_equal %{Showing}, link_to_unless(true, "Showing".html_safe, url_hash) + assert_equal %{Showing}, link_to_unless(false, "Showing".html_safe, url_hash) end def test_link_to_if -- cgit v1.2.3