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
class HTML < CommonMarker::HtmlRenderer
def code_block(node)
block do
code = node.string_content
lang = node.fence_info
lang_attr = lang.present? ? %Q{ lang="#{lang}"} : ''
result =
"<pre>" \
"<code#{lang_attr}>#{ERB::Util.html_escape(code)}</code>" \
"</pre>"
out(result)
out("<pre#{sourcepos(node)}><code")
out(' lang="', node.fence_info, '"') if node.fence_info.present?
out('>')
out(escape_html(node.string_content))
out('</code></pre>')
end
end
end
......
......@@ -40,6 +40,12 @@ describe Banzai::Filter::MarkdownFilter do
expect(result).to start_with("<pre><code>")
end
it 'works with utf8 chars in language' do
result = filter("```日\nsome code\n```")
expect(result).to start_with("<pre><code lang=\"\">")
end
end
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