From 0b02284545dcbed7da40489e0db9bd49eca924b1 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 9 Jun 2011 15:29:17 -0700 Subject: ensuring that json_escape returns html safe strings when passed an html safe string --- activesupport/lib/active_support/core_ext/string/output_safety.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activesupport') 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 -- cgit v1.2.3