Commit f615c877bcb36aa2e4bc399545376671b55f167e
1 parent
822c0a50
Exists in
master
and in
4 other branches
fix can not guess problem
Showing
3 changed files
with
3 additions
and
3 deletions
Show diff stats
app/helpers/application_helper.rb
1 | require 'digest/md5' | 1 | require 'digest/md5' |
2 | module ApplicationHelper | 2 | module ApplicationHelper |
3 | + include Utils::CharEncode | ||
3 | 4 | ||
4 | def gravatar_icon(user_email) | 5 | def gravatar_icon(user_email) |
5 | gravatar_host = request.ssl? ? "https://secure.gravatar.com" : "http://www.gravatar.com" | 6 | gravatar_host = request.ssl? ? "https://secure.gravatar.com" : "http://www.gravatar.com" |
app/helpers/commits_helper.rb
lib/utils.rb
@@ -18,13 +18,14 @@ module Utils | @@ -18,13 +18,14 @@ module Utils | ||
18 | 18 | ||
19 | module CharEncode | 19 | module CharEncode |
20 | def encode(string) | 20 | def encode(string) |
21 | + return '' unless string | ||
21 | cd = CharDet.detect(string) | 22 | cd = CharDet.detect(string) |
22 | if cd.confidence > 0.6 | 23 | if cd.confidence > 0.6 |
23 | string.force_encoding(cd.encoding) | 24 | string.force_encoding(cd.encoding) |
24 | end | 25 | end |
25 | string.encode("utf-8", :undef => :replace, :replace => "?", :invalid => :replace) | 26 | string.encode("utf-8", :undef => :replace, :replace => "?", :invalid => :replace) |
26 | rescue | 27 | rescue |
27 | - "Invalid code encoding" | 28 | + "Invalid Encoding" |
28 | end | 29 | end |
29 | end | 30 | end |
30 | 31 |