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:
authorStan Hu <stanhu@gmail.com>2018-08-29 19:38:17 +0300
committerStan Hu <stanhu@gmail.com>2018-08-29 19:46:46 +0300
commit038be9fffa65a42a7bcd066d0a5d726fd3ab59b1 (patch)
treee90fa1d634b2a872da749cdfd5089f7175013bf6 /spec/lib/gitlab/encoding_helper_spec.rb
parent42523a415df7b58bceb5d5d515e57bda180c02d8 (diff)
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 'spec/lib/gitlab/encoding_helper_spec.rb')
-rw-r--r--spec/lib/gitlab/encoding_helper_spec.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/lib/gitlab/encoding_helper_spec.rb b/spec/lib/gitlab/encoding_helper_spec.rb
index e68c9850f6b..a5bf2f2b3df 100644
--- a/spec/lib/gitlab/encoding_helper_spec.rb
+++ b/spec/lib/gitlab/encoding_helper_spec.rb
@@ -1,3 +1,4 @@
+# coding: utf-8
require "spec_helper"
describe Gitlab::EncodingHelper do
@@ -187,4 +188,15 @@ describe Gitlab::EncodingHelper do
end
end
end
+
+ describe '#binary_stringio' do
+ it 'does not mutate the original string encoding' do
+ test = 'my-test'
+
+ io_stream = ext_class.binary_stringio(test)
+
+ expect(io_stream.external_encoding.name).to eq('ASCII-8BIT')
+ expect(test.encoding.name).to eq('UTF-8')
+ end
+ end
end