aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorMike Virata-Stone <mjstone@on-site.com>2016-08-11 21:57:12 -0700
committerMike Virata-Stone <mjstone@on-site.com>2016-08-11 22:05:48 -0700
commitefd59ab38231eca1084e85aa990321599308757f (patch)
tree46040e745fbe79972609294418d92ce0649701e2 /actionpack
parentfecc67d5152576eb9d918f6a2b90851e8fd6a23c (diff)
downloadrails-efd59ab38231eca1084e85aa990321599308757f.tar.gz
rails-efd59ab38231eca1084e85aa990321599308757f.tar.bz2
rails-efd59ab38231eca1084e85aa990321599308757f.zip
Remove dead code and ensure values are strings before calling gsub
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/helpers/tag_helper.rb3
-rw-r--r--actionpack/test/template/tag_helper_test.rb8
2 files changed, 9 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionpack/lib/action_view/helpers/tag_helper.rb
index 6b659a7c00..e39c58ca32 100644
--- a/actionpack/lib/action_view/helpers/tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/tag_helper.rb
@@ -147,7 +147,6 @@ module ActionView
elsif BOOLEAN_ATTRIBUTES.include?(key)
attrs << %(#{key}="#{key}") if value
elsif !value.nil?
- final_value = value.is_a?(Array) ? value.join(" ") : value
attrs << tag_option(key, value, escape)
end
end
@@ -159,7 +158,7 @@ module ActionView
if value.is_a?(Array)
value = escape ? safe_join(value, " ") : value.join(" ")
else
- value = escape ? ERB::Util.html_escape(value) : value
+ value = escape ? ERB::Util.html_escape(value) : value.to_s
end
%(#{key}="#{value.gsub(/"/, '&quot;'.freeze)}")
end
diff --git a/actionpack/test/template/tag_helper_test.rb b/actionpack/test/template/tag_helper_test.rb
index 9c3d636765..e38c9beb8c 100644
--- a/actionpack/test/template/tag_helper_test.rb
+++ b/actionpack/test/template/tag_helper_test.rb
@@ -29,6 +29,14 @@ class TagHelperTest < ActionView::TestCase
assert_equal "<p included=\"\" />", tag("p", :included => '')
end
+ def test_tag_options_accepts_symbol_option_when_not_escaping
+ assert_equal "<p value=\"symbol\" />", tag("p", { :value => :symbol }, false, false)
+ end
+
+ def test_tag_options_accepts_integer_option_when_not_escaping
+ assert_equal "<p value=\"42\" />", tag("p", { :value => 42 }, false, false)
+ end
+
def test_tag_options_converts_boolean_option
assert_equal '<p disabled="disabled" multiple="multiple" readonly="readonly" />',
tag("p", :disabled => true, :multiple => true, :readonly => true)