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
iv
gitlab-ce
Commits
eb5749ed
Commit
eb5749ed
authored
May 26, 2012
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed encoding problems with plain/text blobs being sent without charset.
parent
cc836914
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
4 deletions
+19
-4
app/controllers/refs_controller.rb
app/controllers/refs_controller.rb
+9
-1
lib/gitlabhq/encode.rb
lib/gitlabhq/encode.rb
+10
-3
No files found.
app/controllers/refs_controller.rb
View file @
eb5749ed
class
RefsController
<
ApplicationController
class
RefsController
<
ApplicationController
include
Gitlabhq
::
Encode
before_filter
:project
before_filter
:project
# Authorize
# Authorize
...
@@ -49,9 +50,16 @@ class RefsController < ApplicationController
...
@@ -49,9 +50,16 @@ class RefsController < ApplicationController
def
blob
def
blob
if
@tree
.
is_blob?
if
@tree
.
is_blob?
if
@tree
.
text?
encoding
=
detect_encoding
(
@tree
.
data
)
mime_type
=
encoding
?
"text/plain; charset=
#{
encoding
}
"
:
"text/plain"
else
mime_type
=
@tree
.
mime_type
end
send_data
(
send_data
(
@tree
.
data
,
@tree
.
data
,
:type
=>
@tree
.
text?
?
"text/plain"
:
@tree
.
mime_type
,
:type
=>
mime_type
,
:disposition
=>
'inline'
,
:disposition
=>
'inline'
,
:filename
=>
@tree
.
name
:filename
=>
@tree
.
name
)
)
...
...
lib/gitlabhq/encode.rb
View file @
eb5749ed
...
@@ -5,9 +5,9 @@ module Gitlabhq
...
@@ -5,9 +5,9 @@ module Gitlabhq
def
utf8
message
def
utf8
message
return
nil
unless
message
return
nil
unless
message
hash
=
CharlockHolmes
::
EncodingDetector
.
detect
(
message
)
rescue
{}
encoding
=
detect_encoding
(
message
)
if
hash
[
:encoding
]
if
encoding
CharlockHolmes
::
Converter
.
convert
(
message
,
hash
[
:encoding
]
,
'UTF-8'
)
CharlockHolmes
::
Converter
.
convert
(
message
,
encoding
,
'UTF-8'
)
else
else
message
message
end
.
force_encoding
(
"utf-8"
)
end
.
force_encoding
(
"utf-8"
)
...
@@ -16,5 +16,12 @@ module Gitlabhq
...
@@ -16,5 +16,12 @@ module Gitlabhq
rescue
rescue
""
""
end
end
def
detect_encoding
message
return
nil
unless
message
hash
=
CharlockHolmes
::
EncodingDetector
.
detect
(
message
)
rescue
{}
return
hash
[
:encoding
]
?
hash
[
:encoding
]
:
nil
end
end
end
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