diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-06-09 15:29:17 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-06-09 15:29:17 -0700 |
commit | 0b02284545dcbed7da40489e0db9bd49eca924b1 (patch) | |
tree | 4b0d4dc0a79b294e7a612c3e0a3256ba2592d60d /activesupport/lib | |
parent | 84f71e42b79f00a97e95f6f472903b553ceda8ef (diff) | |
download | rails-0b02284545dcbed7da40489e0db9bd49eca924b1.tar.gz rails-0b02284545dcbed7da40489e0db9bd49eca924b1.tar.bz2 rails-0b02284545dcbed7da40489e0db9bd49eca924b1.zip |
ensuring that json_escape returns html safe strings when passed an html safe string
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/string/output_safety.rb | 3 |
1 files changed, 2 insertions, 1 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 aeb21ed8df..20e40fe40f 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -51,7 +51,8 @@ class ERB # <%=j @person.to_json %> # def json_escape(s) - s.to_s.gsub(/[&"><]/) { |special| JSON_ESCAPE[special] } + result = s.to_s.gsub(/[&"><]/) { |special| JSON_ESCAPE[special] } + s.html_safe? ? result.html_safe : result end alias j json_escape |