BigW Consortium Gitlab

Commit a1cd582c by Saito Committed by Jeremy Mack

fix can not guess problem

parent 2201ef80
require 'digest/md5' require 'digest/md5'
module ApplicationHelper module ApplicationHelper
include Utils::CharEncode
def gravatar_icon(user_email) def gravatar_icon(user_email)
gravatar_host = request.ssl? ? "https://secure.gravatar.com" : "http://www.gravatar.com" gravatar_host = request.ssl? ? "https://secure.gravatar.com" : "http://www.gravatar.com"
......
module CommitsHelper module CommitsHelper
include Utils::CharEncode
def old_line_number(line, i) def old_line_number(line, i)
end end
......
...@@ -18,13 +18,14 @@ module Utils ...@@ -18,13 +18,14 @@ module Utils
module CharEncode module CharEncode
def encode(string) def encode(string)
return '' unless string
cd = CharDet.detect(string) cd = CharDet.detect(string)
if cd.confidence > 0.6 if cd.confidence > 0.6
string.force_encoding(cd.encoding) string.force_encoding(cd.encoding)
end end
string.encode("utf-8", :undef => :replace, :replace => "?", :invalid => :replace) string.encode("utf-8", :undef => :replace, :replace => "?", :invalid => :replace)
rescue rescue
"Invalid code encoding" "Invalid Encoding"
end end
end end
......
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