Created
December 26, 2018 08:26
-
-
Save aoleg94/702a6633b4c202c0e0851cbe4d58d7f2 to your computer and use it in GitHub Desktop.
Gitlab CP1251 patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd /opt/gitlab && patch -p2 < this-patch | |
--- opt/gitlab/embedded/lib/ruby/gems/2.5.0/gems/gitlab-grit-2.8.2/lib/grit_ext.rb.orig 2018-12-22 01:24:08.000000000 +0500 | |
+++ opt/gitlab/embedded/lib/ruby/gems/2.5.0/gems/gitlab-grit-2.8.2/lib/grit_ext.rb 2018-12-26 13:21:46.792000000 +0500 | |
@@ -22,7 +22,8 @@ | |
# encoding message to detect encoding | |
if detect && detect[:encoding] | |
- message.force_encoding(detect[:encoding]) | |
+ message.force_encoding("windows-1251") | |
+ message.encode("utf-8", "windows-1251", undef: :replace, replace: "", invalid: :replace) | |
end | |
# encode and clean the bad chars | |
--- opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/encoding_helper.rb.orig 2018-12-22 01:24:14.000000000 +0500 | |
+++ opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/encoding_helper.rb 2018-12-26 13:20:10.772000000 +0500 | |
@@ -23,9 +23,10 @@ | |
detect = CharlockHolmes::EncodingDetector.detect(message) | |
return message.force_encoding("BINARY") if detect_binary?(message, detect) | |
- if detect && detect[:encoding] && detect[:confidence] > ENCODING_CONFIDENCE_THRESHOLD | |
+ if detect && detect[:encoding] | |
# force detected encoding if we have sufficient confidence. | |
- message.force_encoding(detect[:encoding]) | |
+ message.force_encoding("windows-1251") | |
+ message.encode("utf-8", "windows-1251", undef: :replace, replace: "", invalid: :replace) | |
end | |
# encode and clean the bad chars |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment