Commit e9325842 authored by Harish Ramachandran's avatar Harish Ramachandran Committed by Jan Provaznik

Refactor changes and test for passed-in HTML

parent 457edc7d
......@@ -55,10 +55,11 @@ module MarkupHelper
# either pure text or emojis, wrapping anything found in the
# requested link
fragment.children.each do |node|
next unless node.text? || node.name == 'gl-emoji'
node.replace(link_to(node.text, url, html_options)) if node.text?
node.replace(link_to(node.to_html.html_safe, url, html_options)) if node.name == 'gl-emoji'
if node.text?
node.replace(link_to(node.text, url, html_options))
elsif node.name == 'gl-emoji'
node.replace(link_to(node.to_html.html_safe, url, html_options))
end
end
end
......
......@@ -232,6 +232,12 @@ describe MarkupHelper do
expect(doc.css('a')[0].attr('href')).to eq link
expect(doc.css('a')[0].text).to eq 'This should finally fix '
end
it "escapes HTML passed as an emoji" do
rendered = '<gl-emoji>&lt;div class="test"&gt;test&lt;/div&gt;</gl-emoji>'
expect(helper.link_to_html(rendered, '/foo'))
.to eq '<a href="/foo"><gl-emoji>&lt;div class="test"&gt;test&lt;/div&gt;</gl-emoji></a>'
end
end
describe '#render_wiki_content' 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