From 2031b75055e6a3cf9cf842d39eb0c4af25ac7ce7 Mon Sep 17 00:00:00 2001 From: Andrei Prigorshnev Date: Wed, 21 Dec 2022 18:21:53 +0400 Subject: [PATCH] FIX: Quoting a mention with status emoji breaks the mention (#19530) --- .../javascripts/discourse/app/lib/to-markdown.js | 4 ++++ .../discourse/tests/unit/lib/to-markdown-test.js | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/app/assets/javascripts/discourse/app/lib/to-markdown.js b/app/assets/javascripts/discourse/app/lib/to-markdown.js index 69be29cfa73..0705cda2a0b 100644 --- a/app/assets/javascripts/discourse/app/lib/to-markdown.js +++ b/app/assets/javascripts/discourse/app/lib/to-markdown.js @@ -379,6 +379,10 @@ export class Tag { } if (cssClass?.includes("emoji")) { + if (cssClass.includes("user-status")) { + return ""; + } + return attr.title || pAttr.title; } diff --git a/app/assets/javascripts/discourse/tests/unit/lib/to-markdown-test.js b/app/assets/javascripts/discourse/tests/unit/lib/to-markdown-test.js index 7bae25d64fe..4c92d6f9389 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/to-markdown-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/to-markdown-test.js @@ -353,6 +353,18 @@ helloWorld();consectetur.`; assert.strictEqual(toMarkdown(html), markdown); }); + test("strips user status from mentions", function (assert) { + const statusHtml = ` + + `; + const html = `Mentioning @andrei${statusHtml}`; + const expectedMarkdown = `Mentioning @andrei`; + + assert.strictEqual(toMarkdown(html), expectedMarkdown); + }); + test("keeps hashtag-cooked and converts to bare hashtag with type", function (assert) { const html = `

This is