Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
f1ac2a61
Commit
f1ac2a61
authored
Nov 09, 2012
by
Saito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove encode lib, clean all encoded area.
parent
96211b01
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
10 additions
and
73 deletions
+10
-73
app/controllers/blob_controller.rb
app/controllers/blob_controller.rb
+0
-1
app/controllers/refs_controller.rb
app/controllers/refs_controller.rb
+0
-1
app/models/commit.rb
app/models/commit.rb
+3
-4
app/models/tree.rb
app/models/tree.rb
+1
-1
app/views/blame/show.html.haml
app/views/blame/show.html.haml
+2
-2
app/views/tree/_blob.html.haml
app/views/tree/_blob.html.haml
+1
-1
app/views/tree/edit.html.haml
app/views/tree/edit.html.haml
+1
-1
config/initializers/3_grit_ext.rb
config/initializers/3_grit_ext.rb
+0
-19
lib/gitlab/encode.rb
lib/gitlab/encode.rb
+0
-41
lib/gitlab/graph/commit.rb
lib/gitlab/graph/commit.rb
+2
-2
No files found.
app/controllers/blob_controller.rb
View file @
f1ac2a61
# Controller for viewing a file's blame
# Controller for viewing a file's blame
class
BlobController
<
ProjectResourceController
class
BlobController
<
ProjectResourceController
include
ExtractsPath
include
ExtractsPath
include
Gitlab
::
Encode
# Authorize
# Authorize
before_filter
:authorize_read_project!
before_filter
:authorize_read_project!
...
...
app/controllers/refs_controller.rb
View file @
f1ac2a61
class
RefsController
<
ProjectResourceController
class
RefsController
<
ProjectResourceController
include
Gitlab
::
Encode
# Authorize
# Authorize
before_filter
:authorize_read_project!
before_filter
:authorize_read_project!
...
...
app/models/commit.rb
View file @
f1ac2a61
class
Commit
class
Commit
include
ActiveModel
::
Conversion
include
ActiveModel
::
Conversion
include
Gitlab
::
Encode
include
StaticModel
include
StaticModel
extend
ActiveModel
::
Naming
extend
ActiveModel
::
Naming
...
@@ -112,7 +111,7 @@ class Commit
...
@@ -112,7 +111,7 @@ class Commit
end
end
def
safe_message
def
safe_message
@safe_message
||=
utf8
message
@safe_message
||=
message
end
end
def
created_at
def
created_at
...
@@ -124,7 +123,7 @@ class Commit
...
@@ -124,7 +123,7 @@ class Commit
end
end
def
author_name
def
author_name
utf8
author
.
name
author
.
name
end
end
# Was this commit committed by a different person than the original author?
# Was this commit committed by a different person than the original author?
...
@@ -133,7 +132,7 @@ class Commit
...
@@ -133,7 +132,7 @@ class Commit
end
end
def
committer_name
def
committer_name
utf8
committer
.
name
committer
.
name
end
end
def
committer_email
def
committer_email
...
...
app/models/tree.rb
View file @
f1ac2a61
...
@@ -8,7 +8,7 @@ class Tree
...
@@ -8,7 +8,7 @@ class Tree
def
initialize
(
raw_tree
,
project
,
ref
=
nil
,
path
=
nil
)
def
initialize
(
raw_tree
,
project
,
ref
=
nil
,
path
=
nil
)
@project
,
@ref
,
@path
=
project
,
ref
,
path
@project
,
@ref
,
@path
=
project
,
ref
,
path
@tree
=
if
path
.
present?
@tree
=
if
path
.
present?
raw_tree
/
path
.
dup
.
force_encoding
(
'ascii-8bit'
)
raw_tree
/
path
else
else
raw_tree
raw_tree
end
end
...
...
app/views/blame/show.html.haml
View file @
f1ac2a61
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
.file_title
.file_title
%i
.icon-file
%i
.icon-file
%span
.file_name
%span
.file_name
=
@tree
.
name
.
force_encoding
(
'utf-8'
)
=
@tree
.
name
%small
=
number_to_human_size
@tree
.
size
%small
=
number_to_human_size
@tree
.
size
%span
.options
=
render
"tree/blob_actions"
%span
.options
=
render
"tree/blob_actions"
.file_content.blame
.file_content.blame
...
@@ -32,4 +32,4 @@
...
@@ -32,4 +32,4 @@
%td
.lines
%td
.lines
=
preserve
do
=
preserve
do
%pre
%pre
=
Gitlab
::
Encode
.
utf8
lines
.
join
(
"
\n
"
)
=
lines
.
join
(
"
\n
"
)
app/views/tree/_blob.html.haml
View file @
f1ac2a61
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
.file_title
.file_title
%i
.icon-file
%i
.icon-file
%span
.file_name
%span
.file_name
=
blob
.
name
.
force_encoding
(
'utf-8'
)
=
blob
.
name
%small
=
number_to_human_size
blob
.
size
%small
=
number_to_human_size
blob
.
size
%span
.options
=
render
"tree/blob_actions"
%span
.options
=
render
"tree/blob_actions"
-
if
blob
.
text?
-
if
blob
.
text?
...
...
app/views/tree/edit.html.haml
View file @
f1ac2a61
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
.file_title
.file_title
%i
.icon-file
%i
.icon-file
%span
.file_name
%span
.file_name
=
"
#{
@tree
.
path
.
force_encoding
(
'utf-8'
)
}
(
#{
@ref
}
)"
=
"
#{
@tree
.
path
}
(
#{
@ref
}
)"
.file_content.code
.file_content.code
#editor
=
@tree
.
data
#editor
=
@tree
.
data
...
...
config/initializers/3_grit_ext.rb
View file @
f1ac2a61
...
@@ -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
Grit
::
Blob
.
class_eval
do
Grit
::
Blob
.
class_eval
do
include
Linguist
::
BlobHelper
include
Linguist
::
BlobHelper
def
data
@data
||=
@repo
.
git
.
cat_file
({
:p
=>
true
},
id
)
Gitlab
::
Encode
.
utf8
@data
end
end
Grit
::
Diff
.
class_eval
do
def
old_path
Gitlab
::
Encode
.
utf8
@a_path
end
def
new_path
Gitlab
::
Encode
.
utf8
@b_path
end
def
diff
Gitlab
::
Encode
.
utf8
@diff
end
end
end
lib/gitlab/encode.rb
deleted
100644 → 0
View file @
96211b01
# Patch Strings to enable detect_encoding! on views
require
'charlock_holmes/string'
module
Gitlab
module
Encode
extend
self
def
utf8
message
# return nil if message is nil
return
nil
unless
message
message
.
force_encoding
(
"utf-8"
)
# return message if message type is binary
detect
=
CharlockHolmes
::
EncodingDetector
.
detect
(
message
)
return
message
if
detect
[
:type
]
==
:binary
# if message is utf-8 encoding, just return it
return
message
if
message
.
valid_encoding?
# if message is not utf-8 encoding, convert it
if
detect
[
:encoding
]
message
.
force_encoding
(
detect
[
:encoding
])
message
.
encode!
(
"utf-8"
,
detect
[
:encoding
],
undef: :replace
,
replace:
""
,
invalid: :replace
)
end
# ensure message encoding is utf8
message
.
valid_encoding?
?
message
:
raise
# Prevent app from crash cause of encoding errors
rescue
encoding
=
detect
?
detect
[
:encoding
]
:
"unknown"
"--broken encoding:
#{
encoding
}
"
end
def
detect_encoding
message
return
nil
unless
message
hash
=
CharlockHolmes
::
EncodingDetector
.
detect
(
message
)
rescue
{}
return
hash
[
:encoding
]
?
hash
[
:encoding
]
:
nil
end
end
end
lib/gitlab/graph/commit.rb
View file @
f1ac2a61
...
@@ -22,13 +22,13 @@ module Gitlab
...
@@ -22,13 +22,13 @@ module Gitlab
h
[
:parents
]
=
self
.
parents
.
collect
do
|
p
|
h
[
:parents
]
=
self
.
parents
.
collect
do
|
p
|
[
p
.
id
,
0
,
0
]
[
p
.
id
,
0
,
0
]
end
end
h
[
:author
]
=
Gitlab
::
Encode
.
utf8
(
author
.
name
)
h
[
:author
]
=
author
.
name
h
[
:time
]
=
time
h
[
:time
]
=
time
h
[
:space
]
=
space
h
[
:space
]
=
space
h
[
:refs
]
=
refs
.
collect
{
|
r
|
r
.
name
}.
join
(
" "
)
unless
refs
.
nil?
h
[
:refs
]
=
refs
.
collect
{
|
r
|
r
.
name
}.
join
(
" "
)
unless
refs
.
nil?
h
[
:id
]
=
sha
h
[
:id
]
=
sha
h
[
:date
]
=
date
h
[
:date
]
=
date
h
[
:message
]
=
escape_once
(
Gitlab
::
Encode
.
utf8
(
message
)
)
h
[
:message
]
=
escape_once
(
message
)
h
[
:login
]
=
author
.
email
h
[
:login
]
=
author
.
email
h
h
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment