Commit f1ac2a616bedc2941bc7f67e2ac25e915da2ddb2
1 parent
96211b01
Exists in
master
and in
4 other branches
remove encode lib, clean all encoded area.
Showing
10 changed files
with
10 additions
and
73 deletions
Show diff stats
app/controllers/blob_controller.rb
app/controllers/refs_controller.rb
app/models/commit.rb
1 | 1 | class Commit |
2 | 2 | include ActiveModel::Conversion |
3 | - include Gitlab::Encode | |
4 | 3 | include StaticModel |
5 | 4 | extend ActiveModel::Naming |
6 | 5 | |
... | ... | @@ -112,7 +111,7 @@ class Commit |
112 | 111 | end |
113 | 112 | |
114 | 113 | def safe_message |
115 | - @safe_message ||= utf8 message | |
114 | + @safe_message ||= message | |
116 | 115 | end |
117 | 116 | |
118 | 117 | def created_at |
... | ... | @@ -124,7 +123,7 @@ class Commit |
124 | 123 | end |
125 | 124 | |
126 | 125 | def author_name |
127 | - utf8 author.name | |
126 | + author.name | |
128 | 127 | end |
129 | 128 | |
130 | 129 | # Was this commit committed by a different person than the original author? |
... | ... | @@ -133,7 +132,7 @@ class Commit |
133 | 132 | end |
134 | 133 | |
135 | 134 | def committer_name |
136 | - utf8 committer.name | |
135 | + committer.name | |
137 | 136 | end |
138 | 137 | |
139 | 138 | def committer_email | ... | ... |
app/models/tree.rb
app/views/blame/show.html.haml
... | ... | @@ -15,7 +15,7 @@ |
15 | 15 | .file_title |
16 | 16 | %i.icon-file |
17 | 17 | %span.file_name |
18 | - = @tree.name.force_encoding('utf-8') | |
18 | + = @tree.name | |
19 | 19 | %small= number_to_human_size @tree.size |
20 | 20 | %span.options= render "tree/blob_actions" |
21 | 21 | .file_content.blame |
... | ... | @@ -32,4 +32,4 @@ |
32 | 32 | %td.lines |
33 | 33 | = preserve do |
34 | 34 | %pre |
35 | - = Gitlab::Encode.utf8 lines.join("\n") | |
35 | + = lines.join("\n") | ... | ... |
app/views/tree/_blob.html.haml
app/views/tree/edit.html.haml
config/initializers/3_grit_ext.rb
... | ... | @@ -6,23 +6,4 @@ Grit::Git.git_max_size = Gitlab.config.git_max_size |
6 | 6 | |
7 | 7 | Grit::Blob.class_eval do |
8 | 8 | include Linguist::BlobHelper |
9 | - | |
10 | - def data | |
11 | - @data ||= @repo.git.cat_file({:p => true}, id) | |
12 | - Gitlab::Encode.utf8 @data | |
13 | - end | |
14 | -end | |
15 | - | |
16 | -Grit::Diff.class_eval do | |
17 | - def old_path | |
18 | - Gitlab::Encode.utf8 @a_path | |
19 | - end | |
20 | - | |
21 | - def new_path | |
22 | - Gitlab::Encode.utf8 @b_path | |
23 | - end | |
24 | - | |
25 | - def diff | |
26 | - Gitlab::Encode.utf8 @diff | |
27 | - end | |
28 | 9 | end | ... | ... |
lib/gitlab/encode.rb
... | ... | @@ -1,41 +0,0 @@ |
1 | -# Patch Strings to enable detect_encoding! on views | |
2 | -require 'charlock_holmes/string' | |
3 | -module Gitlab | |
4 | - module Encode | |
5 | - extend self | |
6 | - | |
7 | - def utf8 message | |
8 | - # return nil if message is nil | |
9 | - return nil unless message | |
10 | - | |
11 | - message.force_encoding("utf-8") | |
12 | - # return message if message type is binary | |
13 | - detect = CharlockHolmes::EncodingDetector.detect(message) | |
14 | - return message if detect[:type] == :binary | |
15 | - | |
16 | - # if message is utf-8 encoding, just return it | |
17 | - return message if message.valid_encoding? | |
18 | - | |
19 | - # if message is not utf-8 encoding, convert it | |
20 | - if detect[:encoding] | |
21 | - message.force_encoding(detect[:encoding]) | |
22 | - message.encode!("utf-8", detect[:encoding], undef: :replace, replace: "", invalid: :replace) | |
23 | - end | |
24 | - | |
25 | - # ensure message encoding is utf8 | |
26 | - message.valid_encoding? ? message : raise | |
27 | - | |
28 | - # Prevent app from crash cause of encoding errors | |
29 | - rescue | |
30 | - encoding = detect ? detect[:encoding] : "unknown" | |
31 | - "--broken encoding: #{encoding}" | |
32 | - end | |
33 | - | |
34 | - def detect_encoding message | |
35 | - return nil unless message | |
36 | - | |
37 | - hash = CharlockHolmes::EncodingDetector.detect(message) rescue {} | |
38 | - return hash[:encoding] ? hash[:encoding] : nil | |
39 | - end | |
40 | - end | |
41 | -end |
lib/gitlab/graph/commit.rb
... | ... | @@ -22,13 +22,13 @@ module Gitlab |
22 | 22 | h[:parents] = self.parents.collect do |p| |
23 | 23 | [p.id,0,0] |
24 | 24 | end |
25 | - h[:author] = Gitlab::Encode.utf8(author.name) | |
25 | + h[:author] = author.name | |
26 | 26 | h[:time] = time |
27 | 27 | h[:space] = space |
28 | 28 | h[:refs] = refs.collect{|r|r.name}.join(" ") unless refs.nil? |
29 | 29 | h[:id] = sha |
30 | 30 | h[:date] = date |
31 | - h[:message] = escape_once(Gitlab::Encode.utf8(message)) | |
31 | + h[:message] = escape_once(message) | |
32 | 32 | h[:login] = author.email |
33 | 33 | h |
34 | 34 | end | ... | ... |