From 1dab1cd5cc9d46724b8d722d994737806ee22bb9 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Fri, 25 Nov 2011 23:15:55 +0000 Subject: [PATCH] Ruby 1.9: fix encoding error on wiki diffs (#4050) WikiDiff#to_html returns a string with ASCII encoding if the WikiJournal content has been Zlib compressed because Zlib::Inflate.inflate returns strings with ASCII encoding. Forcing the encoding to be UTF8 fixes this bug. Contributed by Moritz Breit. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7927 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/wiki_content.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/wiki_content.rb b/app/models/wiki_content.rb index 45640dc71..b1fe60fec 100644 --- a/app/models/wiki_content.rb +++ b/app/models/wiki_content.rb @@ -88,7 +88,9 @@ class WikiContent < ActiveRecord::Base def text @text ||= case compression when 'gzip' - Zlib::Inflate.inflate(data) + str = Zlib::Inflate.inflate(data) + str.force_encoding("UTF-8") if str.respond_to?(:force_encoding) + str else # uncompressed data data