mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Merge pull request #1546 from sikachu/31safebuffer
Fix failing ActionPack tests on 3-1-stable
This commit is contained in:
@@ -51,7 +51,13 @@ module ActionView
|
||||
# This dance is needed because Builder can't use capture
|
||||
pos = output_buffer.length
|
||||
yield
|
||||
fragment = output_buffer.slice!(pos..-1)
|
||||
if output_buffer.is_a?(ActionView::OutputBuffer)
|
||||
safe_output_buffer = output_buffer.to_str
|
||||
fragment = safe_output_buffer.slice!(pos..-1)
|
||||
self.output_buffer = ActionView::OutputBuffer.new(safe_output_buffer)
|
||||
else
|
||||
fragment = output_buffer.slice!(pos..-1)
|
||||
end
|
||||
controller.write_fragment(name, fragment, options)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -255,14 +255,16 @@ module ActionView
|
||||
# simple_format("<span>I'm allowed!</span> It's true.", {}, :sanitize => false)
|
||||
# # => "<p><span>I'm allowed!</span> It's true.</p>"
|
||||
def simple_format(text, html_options={}, options={})
|
||||
text = ''.html_safe if text.nil?
|
||||
text = text ? text.to_str : ''
|
||||
text = text.dup if text.frozen?
|
||||
start_tag = tag('p', html_options, true)
|
||||
text = sanitize(text) unless options[:sanitize] == false
|
||||
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.concat("</p>")
|
||||
text = sanitize(text) unless options[:sanitize] == false
|
||||
text
|
||||
end
|
||||
|
||||
# Creates a Cycle object whose _to_s_ method cycles through elements of an
|
||||
|
||||
@@ -497,14 +497,14 @@ module ActionView
|
||||
}.compact
|
||||
extras = extras.empty? ? '' : '?' + ERB::Util.html_escape(extras.join('&'))
|
||||
|
||||
email_address_obfuscated = email_address.dup
|
||||
email_address_obfuscated = email_address.to_str
|
||||
email_address_obfuscated.gsub!(/@/, html_options.delete("replace_at")) if html_options.key?("replace_at")
|
||||
email_address_obfuscated.gsub!(/\./, html_options.delete("replace_dot")) if html_options.key?("replace_dot")
|
||||
case encode
|
||||
when "javascript"
|
||||
string = ''
|
||||
html = content_tag("a", name || email_address_obfuscated.html_safe, html_options.merge("href" => "mailto:#{email_address}#{extras}".html_safe))
|
||||
html = escape_javascript(html)
|
||||
html = escape_javascript(html.to_str)
|
||||
"document.write('#{html}');".each_byte do |c|
|
||||
string << sprintf("%%%x", c)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user