diff options
author | Stan Hu <stanhu@gmail.com> | 2018-08-29 09:38:17 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-08-29 09:46:46 -0700 |
commit | 038be9fffa65a42a7bcd066d0a5d726fd3ab59b1 (patch) | |
tree | e90fa1d634b2a872da749cdfd5089f7175013bf6 /lib/gitlab/encoding_helper.rb | |
parent | 42523a415df7b58bceb5d5d515e57bda180c02d8 (diff) | |
download | gitlab-ce-038be9fffa65a42a7bcd066d0a5d726fd3ab59b1.tar.gz |
Fix Error 500s due to encoding issues when Wiki hooks fire
Saved Wiki content goes through the GitalyClient::WikiService, which calls
StringIO#set_encoding on the input stream. The problem is that this call
mutates the encoding of the given string object to ASCII-88BIT, which
causes problems for models expecting the data to still be in UTF-8.
Freezing the input disables this behavior:
https://github.com/ruby/ruby/blob/v2_4_4/ext/stringio/stringio.c#L1583
Closes #50590
Diffstat (limited to 'lib/gitlab/encoding_helper.rb')
-rw-r--r-- | lib/gitlab/encoding_helper.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/gitlab/encoding_helper.rb b/lib/gitlab/encoding_helper.rb index d1fd5dfe0cb..0f336fbaa10 100644 --- a/lib/gitlab/encoding_helper.rb +++ b/lib/gitlab/encoding_helper.rb @@ -75,7 +75,7 @@ module Gitlab end def binary_stringio(str) - StringIO.new(str || '').tap { |io| io.set_encoding(Encoding::ASCII_8BIT) } + StringIO.new(str.freeze || '').tap { |io| io.set_encoding(Encoding::ASCII_8BIT) } end private |