Allow emoji in label and milestone references

If we put the emoji filter before the reference filters, each emoji will
have a wrapper element that prevents the reference filter from detecting
the presence of the emoji.

As the emoji filter now runs after the reference filters, references
must contain a literal emoji, not the GitLab Flavored Markdown
versions (:100`, for example).

A weird side-effect is that if you have a label with the 100 emoji, and
a label named 💯, then trying to reference the latter will work (link
to the correct label), but will render with the 100 emoji. I'm
comfortable with that edge case, I think.
This commit is contained in:
Sean McGivern 2019-06-06 17:49:08 +01:00
parent a18b7e7e2b
commit 1617aa2756
No known key found for this signature in database
GPG key ID: 37F9C876C51D0740
3 changed files with 29 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
title: Allow references to labels and milestones to contain emoji
merge_request: 29284
author:
type: changed

View file

@ -25,7 +25,6 @@ module Banzai
Filter::VideoLinkFilter, Filter::VideoLinkFilter,
Filter::ImageLazyLoadFilter, Filter::ImageLazyLoadFilter,
Filter::ImageLinkFilter, Filter::ImageLinkFilter,
Filter::EmojiFilter,
Filter::TableOfContentsFilter, Filter::TableOfContentsFilter,
Filter::AutolinkFilter, Filter::AutolinkFilter,
Filter::ExternalLinkFilter, Filter::ExternalLinkFilter,
@ -34,6 +33,7 @@ module Banzai
*reference_filters, *reference_filters,
Filter::EmojiFilter,
Filter::TaskListFilter, Filter::TaskListFilter,
Filter::InlineDiffFilter, Filter::InlineDiffFilter,

View file

@ -117,4 +117,27 @@ describe Banzai::Pipeline::GfmPipeline do
expect(output).not_to include("javascript") expect(output).not_to include("javascript")
end end
end end
describe 'emoji in references' do
set(:project) { create(:project, :public) }
let(:emoji) { '💯' }
it 'renders a label reference with emoji inside' do
create(:label, project: project, name: emoji)
output = described_class.to_html("#{Label.reference_prefix}\"#{emoji}\"", project: project)
expect(output).to include(emoji)
expect(output).to include(Gitlab::Routing.url_helpers.project_issues_path(project, label_name: emoji))
end
it 'renders a milestone reference with emoji inside' do
milestone = create(:milestone, project: project, title: emoji)
output = described_class.to_html("#{Milestone.reference_prefix}\"#{emoji}\"", project: project)
expect(output).to include(emoji)
expect(output).to include(Gitlab::Routing.url_helpers.milestone_path(milestone))
end
end
end end