summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaito <saitowu@gmail.com>2011-12-13 00:41:31 +0800
committerJeremy Mack <jmacktdkc@gmail.com>2011-12-13 13:20:45 -0500
commita1cd582c67b10abbda6c2fb2c99d8735138d33db (patch)
tree309d12702bf8be39a752e4c0379a2bf2f4467884
parent2201ef80200d0a3f896a30fe10aa3a2c71b7bde1 (diff)
downloadgitlab-ce-a1cd582c67b10abbda6c2fb2c99d8735138d33db.tar.gz
fix can not guess problem
-rw-r--r--app/helpers/application_helper.rb1
-rw-r--r--app/helpers/commits_helper.rb2
-rw-r--r--lib/utils.rb3
3 files changed, 3 insertions, 3 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 2dd652e40f7..2f982dac949 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,5 +1,6 @@
require 'digest/md5'
module ApplicationHelper
+ include Utils::CharEncode
def gravatar_icon(user_email)
gravatar_host = request.ssl? ? "https://secure.gravatar.com" : "http://www.gravatar.com"
diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb
index ae7826712a5..98ec9936f11 100644
--- a/app/helpers/commits_helper.rb
+++ b/app/helpers/commits_helper.rb
@@ -1,6 +1,4 @@
module CommitsHelper
- include Utils::CharEncode
-
def old_line_number(line, i)
end
diff --git a/lib/utils.rb b/lib/utils.rb
index 17c9dfe3dd2..2de14761444 100644
--- a/lib/utils.rb
+++ b/lib/utils.rb
@@ -18,13 +18,14 @@ module Utils
module CharEncode
def encode(string)
+ return '' unless string
cd = CharDet.detect(string)
if cd.confidence > 0.6
string.force_encoding(cd.encoding)
end
string.encode("utf-8", :undef => :replace, :replace => "?", :invalid => :replace)
rescue
- "Invalid code encoding"
+ "Invalid Encoding"
end
end