Commit a3c3776b authored by Stan Hu's avatar Stan Hu

Merge branch...

Merge branch '51271-error-500-due-to-encoding-issues-when-when-attempting-to-access-issues-api' into 'master'

Resolve "Error 500 due to encoding issues when when attempting to access issues API"

Closes #51271

See merge request gitlab-org/gitlab-ce!21680
parents 32062a91 67cf5917
...@@ -4,15 +4,11 @@ module Banzai ...@@ -4,15 +4,11 @@ module Banzai
class HTML < CommonMarker::HtmlRenderer class HTML < CommonMarker::HtmlRenderer
def code_block(node) def code_block(node)
block do block do
code = node.string_content out("<pre#{sourcepos(node)}><code")
lang = node.fence_info out(' lang="', node.fence_info, '"') if node.fence_info.present?
lang_attr = lang.present? ? %Q{ lang="#{lang}"} : '' out('>')
result = out(escape_html(node.string_content))
"<pre>" \ out('</code></pre>')
"<code#{lang_attr}>#{ERB::Util.html_escape(code)}</code>" \
"</pre>"
out(result)
end end
end end
end end
......
...@@ -40,6 +40,12 @@ describe Banzai::Filter::MarkdownFilter do ...@@ -40,6 +40,12 @@ describe Banzai::Filter::MarkdownFilter do
expect(result).to start_with("<pre><code>") expect(result).to start_with("<pre><code>")
end end
it 'works with utf8 chars in language' do
result = filter("```日\nsome code\n```")
expect(result).to start_with("<pre><code lang=\"\">")
end
end end
context 'using Redcarpet' do context 'using Redcarpet' do
......
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