aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2012-04-30 06:47:07 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2012-04-30 06:47:07 -0700
commit7d5146efad1c3bd471f315e4d259e00052eacbb6 (patch)
tree67fd4f0647738b8136873f702564b2cbf8c43e29 /actionpack/lib/action_view
parentbca9a9e926db11c5c9a438493d49317146c64fb6 (diff)
parent16df67b1486d0651494a27d77f8e0469f4f1563f (diff)
downloadrails-7d5146efad1c3bd471f315e4d259e00052eacbb6.tar.gz
rails-7d5146efad1c3bd471f315e4d259e00052eacbb6.tar.bz2
rails-7d5146efad1c3bd471f315e4d259e00052eacbb6.zip
Merge pull request #5705 from lest/patch-3
split CDATA end token in cdata_section helper
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/helpers/tag_helper.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionpack/lib/action_view/helpers/tag_helper.rb
index 23777721f6..f7afa48256 100644
--- a/actionpack/lib/action_view/helpers/tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/tag_helper.rb
@@ -109,8 +109,12 @@ module ActionView
#
# cdata_section(File.read("hello_world.txt"))
# # => <![CDATA[<hello from a text file]]>
+ #
+ # cdata_section("hello]]>world")
+ # # => <![CDATA[hello]]]]><![CDATA[>world]]>
def cdata_section(content)
- "<![CDATA[#{content}]]>".html_safe
+ splitted = content.gsub(']]>', ']]]]><![CDATA[>')
+ "<![CDATA[#{splitted}]]>".html_safe
end
# Returns an escaped version of +html+ without affecting existing escaped entities.