diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2016-01-16 04:23:27 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2016-01-16 04:23:27 -0200 |
commit | f5065ef60c011a0d84224e74e1e8a0b882c36223 (patch) | |
tree | 5632a7405e3e8f061d7ab9e3f0d1e7083d3aadd3 | |
parent | de2259791cd21e80d44ec7c7562324c73ff85699 (diff) | |
parent | 7c988f8030fa5b779041d682c12132ab4da47d1e (diff) | |
download | rails-f5065ef60c011a0d84224e74e1e8a0b882c36223.tar.gz rails-f5065ef60c011a0d84224e74e1e8a0b882c36223.tar.bz2 rails-f5065ef60c011a0d84224e74e1e8a0b882c36223.zip |
Merge pull request #20046 from yoongkang/ladida
Use ActiveSupport::SafeBuffer when flushing content_for
-rw-r--r-- | actionview/CHANGELOG.md | 6 | ||||
-rw-r--r-- | actionview/lib/action_view/flows.rb | 2 | ||||
-rw-r--r-- | actionview/test/template/capture_helper_test.rb | 13 |
3 files changed, 20 insertions, 1 deletions
diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md index e31ce85610..98ac2c1c22 100644 --- a/actionview/CHANGELOG.md +++ b/actionview/CHANGELOG.md @@ -1,3 +1,9 @@ +* Create a new `ActiveSupport::SafeBuffer` instance when `content_for` is flushed. + + Fixes #19890 + + *Yoong Kang Lim* + * Fix `collection_radio_buttons` hidden_field name and make it appear before the actual input radio tags to make the real value override the hidden when passed. diff --git a/actionview/lib/action_view/flows.rb b/actionview/lib/action_view/flows.rb index ba24510e56..bc61920848 100644 --- a/actionview/lib/action_view/flows.rb +++ b/actionview/lib/action_view/flows.rb @@ -15,7 +15,7 @@ module ActionView # Called by each renderer object to set the layout contents. def set(key, value) - @content[key] = value + @content[key] = ActiveSupport::SafeBuffer.new(value) end # Called by content_for diff --git a/actionview/test/template/capture_helper_test.rb b/actionview/test/template/capture_helper_test.rb index 1e099d482c..7e6761e580 100644 --- a/actionview/test/template/capture_helper_test.rb +++ b/actionview/test/template/capture_helper_test.rb @@ -148,6 +148,19 @@ class CaptureHelperTest < ActionView::TestCase assert ! content_for?(:something_else) end + def test_content_for_should_be_html_safe_after_flush_empty + assert ! content_for?(:title) + content_for :title do + content_tag(:p, 'title') + end + assert content_for(:title).html_safe? + content_for :title, "", flush: true + content_for(:title) do + content_tag(:p, 'title') + end + assert content_for(:title).html_safe? + end + def test_provide assert !content_for?(:title) provide :title, "hi" |