Skip to content

A platform for community discussion. Free, open, simple.

FIX: properly render emojis in local oneboxes

Régis Hanol7d7f6faf40c0
diff --git a/lib/oneboxer.rb b/lib/oneboxer.rb
index f89e0426e9b..682251ed505 100644
--- a/lib/oneboxer.rb
+++ b/lib/oneboxer.rb
@@ -206,7 +206,7 @@ module Oneboxer
original_url: url,
title: PrettyText.unescape_emoji(CGI::escapeHTML(topic.title)),
category_html: CategoryBadge.html_for(topic.category),
- quote: post.excerpt(SiteSetting.post_onebox_maxlength),
+ quote: PrettyText.unescape_emoji(post.excerpt(SiteSetting.post_onebox_maxlength)),
}
template = File.read("#{Rails.root}/lib/onebox/templates/discourse_topic_onebox.hbs")
diff --git a/spec/components/oneboxer_spec.rb b/spec/components/oneboxer_spec.rb
index 03525ff10ad..1bbc1e76b50 100644
--- a/spec/components/oneboxer_spec.rb
+++ b/spec/components/oneboxer_spec.rb
@@ -35,7 +35,7 @@ describe Oneboxer do
replier = Fabricate(:user)
- public_post = Fabricate(:post)
+ public_post = Fabricate(:post, raw: "This post has an emoji :+1:")
public_topic = public_post.topic
public_reply = Fabricate(:post, topic: public_topic, post_number: 2, user: replier)
public_hidden = Fabricate(:post, topic: public_topic, post_number: 3, hidden: true)
@@ -48,7 +48,9 @@ describe Oneboxer do
secured_reply = Fabricate(:post, user: staff, topic: secured_topic, post_number: 2)
expect(preview(public_topic.relative_url, user, public_category)).to include(public_topic.title)
- expect(preview(public_post.url, user, public_category)).to include(public_topic.title)
+ onebox = preview(public_post.url, user, public_category)
+ expect(onebox).to include(public_topic.title)
+ expect(onebox).to include("/images/emoji/")
onebox = preview(public_reply.url, user, public_category)
expect(onebox).to include(public_reply.excerpt)