diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /lib/gitlab/encoding_helper.rb | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'lib/gitlab/encoding_helper.rb')
-rw-r--r-- | lib/gitlab/encoding_helper.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/gitlab/encoding_helper.rb b/lib/gitlab/encoding_helper.rb index 8ee53d0de28..50e7631d983 100644 --- a/lib/gitlab/encoding_helper.rb +++ b/lib/gitlab/encoding_helper.rb @@ -64,6 +64,15 @@ module Gitlab detect && detect[:type] == :binary end + # This is like encode_utf8 except we skip autodetection of the encoding. We + # assume the data must be interpreted as UTF-8. + def encode_utf8_no_detect(message) + message = force_encode_utf8(message) + return message if message.valid_encoding? + + message.encode(Encoding::UTF_8, invalid: :replace, undef: :replace) + end + def encode_utf8(message, replace: "") message = force_encode_utf8(message) return message if message.valid_encoding? |