WikiContent::Version#text may return ascii-8bit encoded string (#10590).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9329 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-04-06 07:21:51 +00:00
parent e964135b62
commit f1cae4f7af
1 changed files with 8 additions and 6 deletions

View File

@ -91,14 +91,16 @@ class WikiContent < ActiveRecord::Base
end
def text
@text ||= case compression
when 'gzip'
str = Zlib::Inflate.inflate(data)
@text ||= begin
str = case compression
when 'gzip'
Zlib::Inflate.inflate(data)
else
# uncompressed data
data
end
str.force_encoding("UTF-8") if str.respond_to?(:force_encoding)
str
else
# uncompressed data
data
end
end