Commit 8479b3b6 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'sh-fix-error-500-updating-wikis' into 'master'

Fix Error 500s due to encoding issues when Wiki hooks fire

Closes #50590

See merge request gitlab-org/gitlab-ce!21414
parents f981d4fe fda12a61
---
title: Fix Error 500s due to encoding issues when Wiki hooks fire
merge_request: 21414
author:
type: fixed
......@@ -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
......
# 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment