summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/helpers/application_helper.rb3
-rw-r--r--spec/helpers/application_helper_spec.rb9
2 files changed, 11 insertions, 1 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index cc49b89191b..e6d50bea4d1 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -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
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 510b76fa9df..2db67cfdf95 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -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