diff options
author | SAKATA Sinji <contact@sinjis-view.mydns.jp> | 2015-10-01 13:09:07 +0900 |
---|---|---|
committer | SAKATA Sinji <contact@sinjis-view.mydns.jp> | 2015-10-02 01:26:19 +0900 |
commit | a3c6ed5c4650a7c8643e57929a34a219c6a15a8a (patch) | |
tree | d9200e26a35212d874631a6e43d78dbe68926971 | |
parent | 54452412f765d9e6e6166e105db9adbc7553aec2 (diff) | |
download | gitlab-ce-a3c6ed5c4650a7c8643e57929a34a219c6a15a8a.tar.gz |
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 |