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
This commit is contained in:
Toshi MARUYAMA 2011-11-25 23:15:55 +00:00
parent 7ed7d8984d
commit 1dab1cd5cc
1 changed files with 3 additions and 1 deletions

View File

@ -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