Commit 60db8684 authored by Moritz Breit's avatar Moritz Breit

[#707] Fix encoding error on wiki diffs on Ruby 1.9

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.
parent 0462fa97
...@@ -104,7 +104,12 @@ class WikiContent < ActiveRecord::Base ...@@ -104,7 +104,12 @@ class WikiContent < ActiveRecord::Base
def text def text
@text ||= case changes["compression"] @text ||= case changes["compression"]
when "gzip" when "gzip"
Zlib::Inflate.inflate(changes["data"]) data = Zlib::Inflate.inflate(changes["data"])
if data.respond_to? :force_encoding
data.force_encoding("UTF-8")
else
data
end
else else
# uncompressed data # uncompressed data
changes["data"] changes["data"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment