diff options
author | Stan Hu <stanhu@gmail.com> | 2015-10-01 14:10:34 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2015-10-01 14:10:34 -0700 |
commit | 1c53c28c795f70536da74fecf0cd7abfaeacd2a5 (patch) | |
tree | 02e3de8beeda5a79ac73f778b632dbc07b43a875 | |
parent | 3fa8bd0e67233cb3636490fb35993e2db3424772 (diff) | |
parent | a3c6ed5c4650a7c8643e57929a34a219c6a15a8a (diff) | |
download | gitlab-ce-1c53c28c795f70536da74fecf0cd7abfaeacd2a5.tar.gz |
Merge pull request #9684 from NKMR6194/master
Fix link with emoji
-rw-r--r-- | app/helpers/gitlab_markdown_helper.rb | 2 | ||||
-rw-r--r-- | spec/helpers/gitlab_markdown_helper_spec.rb | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb index 153a44870f6..12b87dca798 100644 --- a/app/helpers/gitlab_markdown_helper.rb +++ b/app/helpers/gitlab_markdown_helper.rb @@ -21,7 +21,7 @@ module GitlabMarkdownHelper gfm_body = Gitlab::Markdown.gfm(escaped_body, project: @project, current_user: current_user) - fragment = Nokogiri::XML::DocumentFragment.parse(gfm_body) + fragment = Nokogiri::HTML::DocumentFragment.parse(gfm_body) if fragment.children.size == 1 && fragment.children[0].name == 'a' # Fragment has only one node, and it's a link generated by `gfm`. # Replace it with our requested link. diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb index be0e0c747b7..20ae29e2bd3 100644 --- a/spec/helpers/gitlab_markdown_helper_spec.rb +++ b/spec/helpers/gitlab_markdown_helper_spec.rb @@ -106,6 +106,12 @@ describe GitlabMarkdownHelper do act = link_to_gfm(text, '/foo') expect(act).to eq %Q(<a href="/foo">#{issues[0].to_reference}</a>) end + + it 'should replace commit message with emoji to link' do + actual = link_to_gfm(':book:Book', '/foo') + expect(actual). + to eq %Q(<img class="emoji" title=":book:" alt=":book:" src="http://localhost/assets/emoji/1F4D6.png" height="20" width="20" align="absmiddle"><a href="/foo">Book</a>) + end end describe '#render_wiki_content' do |