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
Léo-Paul Géneau
gitlab-ce
Commits
1f2cc29c
Commit
1f2cc29c
authored
Mar 22, 2018
by
Ahmad Sherif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix EncodingHelper#clean blowing up on UTF-16BE strings
Closes gitaly#1101
parent
5c36e1b9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
1 deletion
+6
-1
lib/gitlab/encoding_helper.rb
lib/gitlab/encoding_helper.rb
+1
-1
spec/lib/gitlab/encoding_helper_spec.rb
spec/lib/gitlab/encoding_helper_spec.rb
+5
-0
No files found.
lib/gitlab/encoding_helper.rb
View file @
1f2cc29c
...
...
@@ -90,7 +90,7 @@ module Gitlab
end
def
clean
(
message
)
message
.
encode
(
"UTF-16BE"
,
undef: :replace
,
invalid: :replace
,
replace:
""
)
message
.
encode
(
"UTF-16BE"
,
undef: :replace
,
invalid: :replace
,
replace:
""
.
encode
(
"UTF-16BE"
)
)
.
encode
(
"UTF-8"
)
.
gsub
(
"
\0
"
.
encode
(
"UTF-8"
),
""
)
end
...
...
spec/lib/gitlab/encoding_helper_spec.rb
View file @
1f2cc29c
...
...
@@ -161,6 +161,11 @@ describe Gitlab::EncodingHelper do
'removes invalid bytes from ASCII-8bit encoded multibyte string.'
,
"Lorem ipsum
\xC3\n
dolor sit amet, xy
\xC3\xA0
y
\xC3\xB9
abcd
\xC3\xB9
efg"
.
force_encoding
(
'ASCII-8BIT'
),
"Lorem ipsum
\n
dolor sit amet, xyàyùabcdùefg"
],
[
'handles UTF-16BE encoded strings'
,
"
\xFE\xFF\x00\x41
"
.
force_encoding
(
'ASCII-8BIT'
),
# An "A" prepended with UTF-16 BOM
"
\xEF\xBB\xBF
A"
# An "A" prepended with UTF-8 BOM
]
].
each
do
|
description
,
test_string
,
xpect
|
it
description
do
...
...
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