aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-11-15 19:45:46 +0100
committerXavier Noria <fxn@hashref.com>2010-11-15 19:45:46 +0100
commit91a6db90cf8b2c07af4cf64a9c587268106aadd5 (patch)
treedbc677fcc9d6a627f9b894bffddaf90d43a576c7 /actionpack/lib/action_view
parent7c5c1a07c03ec03536636c26e09b80b29a59beed (diff)
parentc2c2b8b96220b11eb3512b1eaaf7985c84f03d67 (diff)
downloadrails-91a6db90cf8b2c07af4cf64a9c587268106aadd5.tar.gz
rails-91a6db90cf8b2c07af4cf64a9c587268106aadd5.tar.bz2
rails-91a6db90cf8b2c07af4cf64a9c587268106aadd5.zip
Merge branch 'master' of git://github.com/lifo/docrails
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/helpers/text_helper.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb
index 7c877a0f57..3d276000a1 100644
--- a/actionpack/lib/action_view/helpers/text_helper.rb
+++ b/actionpack/lib/action_view/helpers/text_helper.rb
@@ -9,6 +9,24 @@ module ActionView
# and transforming strings, which can reduce the amount of inline Ruby code in
# your views. These helper methods extend Action View making them callable
# within your template files.
+ #
+ # ==== Sanitization
+ #
+ # Most text helpers by default sanitize the given content, but do not escape it.
+ # This means HTML tags will appear in the page but all malicious code will be removed.
+ # Let's look at some examples using the +simple_format+ method:
+ #
+ # simple_format('<a href="http://example.com/">Example</a>')
+ # # => "<p><a href=\"http://example.com/\">Example</a></p>"
+ #
+ # simple_format('<a href="javascript:alert('no!')">Example</a>')
+ # # => "<p><a>Example</a></p>"
+ #
+ # If you want to escape all content, you should invoke the +h+ method before
+ # calling the text helper.
+ #
+ # simple_format h('<a href="http://example.com/">Example</a>')
+ # # => "<p>&lt;a href=\"http://example.com/\"&gt;Example&lt;/a&gt;</p>"
module TextHelper
extend ActiveSupport::Concern