Force of markup output to be the input encoding

This commit is contained in:
Robert Schilling
2014-08-11 12:18:07 +02:00
parent e794b56133
commit 8265d43d01
2 changed files with 11 additions and 1 deletions
+2 -1
View File
@@ -221,7 +221,8 @@ module ApplicationHelper
end
def render_markup(file_name, file_content)
GitHub::Markup.render(file_name, file_content).html_safe
GitHub::Markup.render(file_name, file_content).
force_encoding(file_content.encoding).html_safe
rescue RuntimeError
simple_format(file_content)
end
+9
View File
@@ -217,4 +217,13 @@ describe ApplicationHelper do
).to eq("<a href=\"http://www.example.com\" rel=\"noreferrer nofollow\">Example</a>")
end
end
describe 'markup_render' do
let(:content) { 'Noël' }
it 'should preserve encoding' do
content.encoding.name.should == 'UTF-8'
expect(render_markup('foo.rst', content).encoding.name).to eq('UTF-8')
end
end
end