FIX: Quoting a mention with status emoji breaks the mention (#19530)

This commit is contained in:
Andrei Prigorshnev 2022-12-21 18:21:53 +04:00 committed by GitHub
parent 8f9933d1dd
commit 2031b75055
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -379,6 +379,10 @@ export class Tag {
} }
if (cssClass?.includes("emoji")) { if (cssClass?.includes("emoji")) {
if (cssClass.includes("user-status")) {
return "";
}
return attr.title || pAttr.title; return attr.title || pAttr.title;
} }

View File

@ -353,6 +353,18 @@ helloWorld();</code>consectetur.`;
assert.strictEqual(toMarkdown(html), markdown); assert.strictEqual(toMarkdown(html), markdown);
}); });
test("strips user status from mentions", function (assert) {
const statusHtml = `
<img class="emoji user-status"
src="/images/emoji/twitter/desert_island.png?v=12"
title="vacation">
`;
const html = `Mentioning <a class="mention" href="/u/andrei">@andrei${statusHtml}</a>`;
const expectedMarkdown = `Mentioning @andrei`;
assert.strictEqual(toMarkdown(html), expectedMarkdown);
});
test("keeps hashtag-cooked and converts to bare hashtag with type", function (assert) { test("keeps hashtag-cooked and converts to bare hashtag with type", function (assert) {
const html = ` const html = `
<p dir="ltr">This is <a class="hashtag-cooked" href="/c/ux/14" data-type="category" data-slug="ux"> <p dir="ltr">This is <a class="hashtag-cooked" href="/c/ux/14" data-type="category" data-slug="ux">