BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
1 deletion
+6
-1
encoding_helper.rb
lib/gitlab/encoding_helper.rb
+1
-1
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
...
@@ -90,7 +90,7 @@ module Gitlab
end
end
def
clean
(
message
)
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"
)
.
encode
(
"UTF-8"
)
.
gsub
(
"
\0
"
.
encode
(
"UTF-8"
),
""
)
.
gsub
(
"
\0
"
.
encode
(
"UTF-8"
),
""
)
end
end
...
...
spec/lib/gitlab/encoding_helper_spec.rb
View file @
1f2cc29c
...
@@ -161,6 +161,11 @@ describe Gitlab::EncodingHelper do
...
@@ -161,6 +161,11 @@ describe Gitlab::EncodingHelper do
'removes invalid bytes from ASCII-8bit encoded multibyte string.'
,
'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
\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"
"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
|
].
each
do
|
description
,
test_string
,
xpect
|
it
description
do
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