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
1 | # Controller for viewing a file's blame | 1 | # Controller for viewing a file's blame |
2 | class BlobController < ProjectResourceController | 2 | class BlobController < ProjectResourceController |
3 | include ExtractsPath | 3 | include ExtractsPath |
4 | - include Gitlab::Encode | ||
5 | 4 | ||
6 | # Authorize | 5 | # Authorize |
7 | before_filter :authorize_read_project! | 6 | before_filter :authorize_read_project! |
app/controllers/refs_controller.rb
app/models/commit.rb
1 | class Commit | 1 | class Commit |
2 | include ActiveModel::Conversion | 2 | include ActiveModel::Conversion |
3 | - include Gitlab::Encode | ||
4 | include StaticModel | 3 | include StaticModel |
5 | extend ActiveModel::Naming | 4 | extend ActiveModel::Naming |
6 | 5 | ||
@@ -112,7 +111,7 @@ class Commit | @@ -112,7 +111,7 @@ class Commit | ||
112 | end | 111 | end |
113 | 112 | ||
114 | def safe_message | 113 | def safe_message |
115 | - @safe_message ||= utf8 message | 114 | + @safe_message ||= message |
116 | end | 115 | end |
117 | 116 | ||
118 | def created_at | 117 | def created_at |
@@ -124,7 +123,7 @@ class Commit | @@ -124,7 +123,7 @@ class Commit | ||
124 | end | 123 | end |
125 | 124 | ||
126 | def author_name | 125 | def author_name |
127 | - utf8 author.name | 126 | + author.name |
128 | end | 127 | end |
129 | 128 | ||
130 | # Was this commit committed by a different person than the original author? | 129 | # Was this commit committed by a different person than the original author? |
@@ -133,7 +132,7 @@ class Commit | @@ -133,7 +132,7 @@ class Commit | ||
133 | end | 132 | end |
134 | 133 | ||
135 | def committer_name | 134 | def committer_name |
136 | - utf8 committer.name | 135 | + committer.name |
137 | end | 136 | end |
138 | 137 | ||
139 | def committer_email | 138 | def committer_email |
app/models/tree.rb
@@ -8,7 +8,7 @@ class Tree | @@ -8,7 +8,7 @@ class Tree | ||
8 | def initialize(raw_tree, project, ref = nil, path = nil) | 8 | def initialize(raw_tree, project, ref = nil, path = nil) |
9 | @project, @ref, @path = project, ref, path | 9 | @project, @ref, @path = project, ref, path |
10 | @tree = if path.present? | 10 | @tree = if path.present? |
11 | - raw_tree / path.dup.force_encoding('ascii-8bit') | 11 | + raw_tree / path |
12 | else | 12 | else |
13 | raw_tree | 13 | raw_tree |
14 | end | 14 | end |
app/views/blame/show.html.haml
@@ -15,7 +15,7 @@ | @@ -15,7 +15,7 @@ | ||
15 | .file_title | 15 | .file_title |
16 | %i.icon-file | 16 | %i.icon-file |
17 | %span.file_name | 17 | %span.file_name |
18 | - = @tree.name.force_encoding('utf-8') | 18 | + = @tree.name |
19 | %small= number_to_human_size @tree.size | 19 | %small= number_to_human_size @tree.size |
20 | %span.options= render "tree/blob_actions" | 20 | %span.options= render "tree/blob_actions" |
21 | .file_content.blame | 21 | .file_content.blame |
@@ -32,4 +32,4 @@ | @@ -32,4 +32,4 @@ | ||
32 | %td.lines | 32 | %td.lines |
33 | = preserve do | 33 | = preserve do |
34 | %pre | 34 | %pre |
35 | - = Gitlab::Encode.utf8 lines.join("\n") | 35 | + = lines.join("\n") |
app/views/tree/_blob.html.haml
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | .file_title | 2 | .file_title |
3 | %i.icon-file | 3 | %i.icon-file |
4 | %span.file_name | 4 | %span.file_name |
5 | - = blob.name.force_encoding('utf-8') | 5 | + = blob.name |
6 | %small= number_to_human_size blob.size | 6 | %small= number_to_human_size blob.size |
7 | %span.options= render "tree/blob_actions" | 7 | %span.options= render "tree/blob_actions" |
8 | - if blob.text? | 8 | - if blob.text? |
app/views/tree/edit.html.haml
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | .file_title | 4 | .file_title |
5 | %i.icon-file | 5 | %i.icon-file |
6 | %span.file_name | 6 | %span.file_name |
7 | - = "#{@tree.path.force_encoding('utf-8')} (#{@ref})" | 7 | + = "#{@tree.path} (#{@ref})" |
8 | .file_content.code | 8 | .file_content.code |
9 | #editor= @tree.data | 9 | #editor= @tree.data |
10 | 10 |
config/initializers/3_grit_ext.rb
@@ -6,23 +6,4 @@ Grit::Git.git_max_size = Gitlab.config.git_max_size | @@ -6,23 +6,4 @@ Grit::Git.git_max_size = Gitlab.config.git_max_size | ||
6 | 6 | ||
7 | Grit::Blob.class_eval do | 7 | Grit::Blob.class_eval do |
8 | include Linguist::BlobHelper | 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 | end | 9 | end |
lib/gitlab/encode.rb
@@ -1,41 +0,0 @@ | @@ -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,13 +22,13 @@ module Gitlab | ||
22 | h[:parents] = self.parents.collect do |p| | 22 | h[:parents] = self.parents.collect do |p| |
23 | [p.id,0,0] | 23 | [p.id,0,0] |
24 | end | 24 | end |
25 | - h[:author] = Gitlab::Encode.utf8(author.name) | 25 | + h[:author] = author.name |
26 | h[:time] = time | 26 | h[:time] = time |
27 | h[:space] = space | 27 | h[:space] = space |
28 | h[:refs] = refs.collect{|r|r.name}.join(" ") unless refs.nil? | 28 | h[:refs] = refs.collect{|r|r.name}.join(" ") unless refs.nil? |
29 | h[:id] = sha | 29 | h[:id] = sha |
30 | h[:date] = date | 30 | h[:date] = date |
31 | - h[:message] = escape_once(Gitlab::Encode.utf8(message)) | 31 | + h[:message] = escape_once(message) |
32 | h[:login] = author.email | 32 | h[:login] = author.email |
33 | h | 33 | h |
34 | end | 34 | end |