Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-09 18:07:45 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-09 18:07:45 +0300
commitf1a40d0db939dfe8ff95d385e652ff72566be765 (patch)
treecdca36cb171cdffff2739c37c23e74914e57a836 /lib/gitlab/encoding_helper.rb
parentac1dca43baa7b3b1ac7d60d89ad60fdeefed0b80 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/encoding_helper.rb')
-rw-r--r--lib/gitlab/encoding_helper.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/gitlab/encoding_helper.rb b/lib/gitlab/encoding_helper.rb
index 88729babb2b..67f8d691a77 100644
--- a/lib/gitlab/encoding_helper.rb
+++ b/lib/gitlab/encoding_helper.rb
@@ -50,7 +50,7 @@ module Gitlab
detect && detect[:type] == :binary
end
- def encode_utf8(message)
+ def encode_utf8(message, replace: "")
message = force_encode_utf8(message)
return message if message.valid_encoding?
@@ -64,7 +64,7 @@ module Gitlab
''
end
else
- clean(message)
+ clean(message, replace: replace)
end
rescue ArgumentError
nil
@@ -94,8 +94,13 @@ module Gitlab
message.force_encoding("UTF-8")
end
- def clean(message)
- message.encode("UTF-16BE", undef: :replace, invalid: :replace, replace: "".encode("UTF-16BE"))
+ def clean(message, replace: "")
+ message.encode(
+ "UTF-16BE",
+ undef: :replace,
+ invalid: :replace,
+ replace: replace.encode("UTF-16BE")
+ )
.encode("UTF-8")
.gsub("\0".encode("UTF-8"), "")
end