Skip to content

Commit 1cdf4dd

Browse files
committed
Fix broken encoding windows-1251 in GitLab 10.6.4
1 parent b211d88 commit 1cdf4dd

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

encoding_helper.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ def encode!(message)
2121
detect = CharlockHolmes::EncodingDetector.detect(message)
2222
return message.force_encoding("BINARY") if detect_binary?(message, detect)
2323

24-
if detect && detect[:encoding] && detect[:confidence] > ENCODING_CONFIDENCE_THRESHOLD
24+
if detect && detect[:encoding]
2525
# force detected encoding if we have sufficient confidence.
26-
message.force_encoding(detect[:encoding])
26+
message.force_encoding("windows-1251")
27+
message.encode("utf-8", "windows-1251", undef: :replace, replace: "", invalid: :replace)
2728
end
2829

2930
# encode and clean the bad chars

grit_ext.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def encode!(message)
2222

2323
# encoding message to detect encoding
2424
if detect && detect[:encoding]
25-
message.force_encoding(detect[:encoding])
25+
message.force_encoding("windows-1251")
26+
message.encode("utf-8", "windows-1251", undef: :replace, replace: "", invalid: :replace)
2627
end
2728

2829
# encode and clean the bad chars

0 commit comments

Comments
 (0)