From 414e820a690bcaeb0577ce095ba33ca8c9220c18 Mon Sep 17 00:00:00 2001
From: Alex Eagle <eagle.alex@gmail.com>
Date: Tue, 3 Apr 2012 11:58:05 +0400
Subject: [PATCH] Force encoding string from data binary always (not only
 compressed)

---
 app/models/wiki_content.rb |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/app/models/wiki_content.rb b/app/models/wiki_content.rb
index 430e9a5..d5a3870 100644
--- a/app/models/wiki_content.rb
+++ b/app/models/wiki_content.rb
@@ -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
 
-- 
1.7.9.4

