aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-05-28 16:56:09 -0500
committerJeremy Kemper <jeremy@bitsweat.net>2009-05-28 17:12:48 -0500
commite23554d79e2db2324144f3ab58f82a895b93fbf5 (patch)
tree35b715035f77d0488294f930ad42dece27076035 /actionpack/lib
parentd120f9de7e150ea6a5f21c834c1f1d0a9ea25d1a (diff)
downloadrails-e23554d79e2db2324144f3ab58f82a895b93fbf5.tar.gz
rails-e23554d79e2db2324144f3ab58f82a895b93fbf5.tar.bz2
rails-e23554d79e2db2324144f3ab58f82a895b93fbf5.zip
Ruby 1.9: flushing the output buffer preserves its encoding
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_view/helpers/capture_helper.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/helpers/capture_helper.rb b/actionpack/lib/action_view/helpers/capture_helper.rb
index 9e39536653..b4197479a0 100644
--- a/actionpack/lib/action_view/helpers/capture_helper.rb
+++ b/actionpack/lib/action_view/helpers/capture_helper.rb
@@ -124,7 +124,11 @@ module ActionView
# Use an alternate output buffer for the duration of the block.
# Defaults to a new empty string.
- def with_output_buffer(buf = '') #:nodoc:
+ def with_output_buffer(buf = nil) #:nodoc:
+ unless buf
+ buf = ''
+ buf.force_encoding(output_buffer.encoding) if buf.respond_to?(:force_encoding)
+ end
self.output_buffer, old_buffer = buf, output_buffer
yield
output_buffer
@@ -134,9 +138,12 @@ module ActionView
# Add the output buffer to the response body and start a new one.
def flush_output_buffer #:nodoc:
- if output_buffer && output_buffer != ''
+ if output_buffer && !output_buffer.empty?
response.body_parts << output_buffer
- self.output_buffer = ''
+ new = ''
+ new.force_encoding(output_buffer.encoding) if new.respond_to?(:force_encoding)
+ self.output_buffer = new
+ nil
end
end
end