diff options
-rw-r--r-- | actionpack/lib/action_view/helpers/text_helper.rb | 3 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/string/output_safety.rb | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb index 75422a343d..8f97eb7d75 100644 --- a/actionpack/lib/action_view/helpers/text_helper.rb +++ b/actionpack/lib/action_view/helpers/text_helper.rb @@ -258,11 +258,12 @@ module ActionView text = ''.html_safe if text.nil? start_tag = tag('p', html_options, true) text = sanitize(text) unless options[:sanitize] == false + text = text.to_str text.gsub!(/\r\n?/, "\n") # \r\n and \r -> \n text.gsub!(/\n\n+/, "</p>\n\n#{start_tag}") # 2+ newline -> paragraph text.gsub!(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br text.insert 0, start_tag - text.html_safe.safe_concat("</p>") + text = ActiveSupport::SafeBuffer.new(text).safe_concat("</p>") end # Creates a Cycle object whose _to_s_ method cycles through elements of an 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 6df987eb14..aeb21ed8df 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -112,7 +112,7 @@ module ActiveSupport #:nodoc: to_str.to_yaml(*args) end - for unsafe_method in UNSAFE_STRING_METHODS + UNSAFE_STRING_METHODS.each do |unsafe_method| class_eval <<-EOT, __FILE__, __LINE__ def #{unsafe_method}(*args) super.to_str |