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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
6b53add3
Commit
6b53add3
authored
Jun 06, 2017
by
James Lopez
Committed by
Rémy Coutable
Jun 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix binary encoding error on MR diffs
parent
b9fcc48a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
1 deletion
+16
-1
changelogs/unreleased/fix-encoding-binary-issue.yml
changelogs/unreleased/fix-encoding-binary-issue.yml
+4
-0
lib/gitlab/encoding_helper.rb
lib/gitlab/encoding_helper.rb
+1
-1
spec/models/merge_request_diff_spec.rb
spec/models/merge_request_diff_spec.rb
+11
-0
No files found.
changelogs/unreleased/fix-encoding-binary-issue.yml
0 → 100644
View file @
6b53add3
---
title
:
Fix binary encoding error on MR diffs
merge_request
:
11929
author
:
lib/gitlab/encoding_helper.rb
View file @
6b53add3
...
@@ -38,7 +38,7 @@ module Gitlab
...
@@ -38,7 +38,7 @@ module Gitlab
def
encode_utf8
(
message
)
def
encode_utf8
(
message
)
detect
=
CharlockHolmes
::
EncodingDetector
.
detect
(
message
)
detect
=
CharlockHolmes
::
EncodingDetector
.
detect
(
message
)
if
detect
if
detect
&&
detect
[
:encoding
]
begin
begin
CharlockHolmes
::
Converter
.
convert
(
message
,
detect
[
:encoding
],
'UTF-8'
)
CharlockHolmes
::
Converter
.
convert
(
message
,
detect
[
:encoding
],
'UTF-8'
)
rescue
ArgumentError
=>
e
rescue
ArgumentError
=>
e
...
...
spec/models/merge_request_diff_spec.rb
View file @
6b53add3
...
@@ -139,4 +139,15 @@ describe MergeRequestDiff, models: true do
...
@@ -139,4 +139,15 @@ describe MergeRequestDiff, models: true do
expect
(
subject
.
commits_count
).
to
eq
2
expect
(
subject
.
commits_count
).
to
eq
2
end
end
end
end
describe
'#utf8_st_diffs'
do
it
'does not raise error when a hash value is in binary'
do
subject
.
st_diffs
=
[
{
diff:
"
\0
"
},
{
diff:
"
\x05\x00\x68\x65\x6c\x6c\x6f
"
}
]
expect
{
subject
.
utf8_st_diffs
}.
not_to
raise_error
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