From 1dab1cd5cc9d46724b8d722d994737806ee22bb9 2011-11-25 23:15:55 From: Toshi MARUYAMA Date: 2011-11-25 23:15:55 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 --- diff --git a/app/models/wiki_content.rb b/app/models/wiki_content.rb index 45640dc..b1fe60f 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