FIX: Single line emojis has emoji metadata indexed twice.

This commit fixes a bug where we our `HTMLScrubber` was only searching
for emoji img tags which contains only the "emoji" class. However, our emoji image tags
may contain more than just the "emoji" class like "only-emoji" when an
emoji exists by itself on a single line.
This commit is contained in:
Alan Guo Xiang Tan 2022-01-24 13:35:30 +08:00
parent 48e5d1af03
commit 77137c5d29
2 changed files with 4 additions and 2 deletions

View File

@ -328,7 +328,7 @@ class SearchIndexer
end
end
document.css("img[class='emoji']").each do |node|
document.css("img.emoji").each do |node|
node.remove_attribute("alt")
end

View File

@ -61,8 +61,10 @@ describe SearchIndexer do
end
it 'extracts emoji name from emoji image' do
html = %Q|<img src="#{Discourse.base_url_no_prefix}/images/emoji/twitter/wink.png?v=9" title=":wink:" class="emoji" alt=":wink:">|
emoji = Emoji["wink"]
html = %Q|<img src=\"#{URI.join(Discourse.base_url_no_prefix, emoji.url)}\" title=\":wink:\" class=\"emoji only-emoji\" alt=\":wink:\">|
scrubbed = scrub(html)
expect(scrubbed).to eq(':wink:')
end