aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuval Kordov <uberllama@gmail.com>2014-02-12 08:22:13 -0700
committerYuval Kordov <uberllama@gmail.com>2014-02-12 08:22:13 -0700
commit30639e1d107b70abc338bc786943db1d88d31e0d (patch)
tree73a30ecba1574bb061db9285217a949cd287bdb0
parent7d5454dcdd7c037658bc62ab3af177e5ca3b69ad (diff)
downloadrails-30639e1d107b70abc338bc786943db1d88d31e0d.tar.gz
rails-30639e1d107b70abc338bc786943db1d88d31e0d.tar.bz2
rails-30639e1d107b70abc338bc786943db1d88d31e0d.zip
Amended json_escape comment to clarify that user-generated content must still be html_escaped if being inserted ingot he DOM via JQuery's html() method.
-rw-r--r--activesupport/lib/active_support/core_ext/string/output_safety.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb
index eb02b6a442..1f9a953d93 100644
--- a/activesupport/lib/active_support/core_ext/string/output_safety.rb
+++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -78,6 +78,11 @@ class ERB
# automatically flag the result as HTML safe, since the raw value is unsafe to
# use inside HTML attributes.
#
+ # If your JSON is being used downstream for insertion into the DOM, be aware of
+ # whether or not it is being inserted via +html()+. Most JQuery plugins do this.
+ # If that is the case, be sure to +html_escape+ or +sanitize+ any user-generated
+ # content returned by your JSON.
+ #
# If you need to output JSON elsewhere in your HTML, you can just do something
# like this, as any unsafe characters (including quotation marks) will be
# automatically escaped for you: