# 回复以提及开头的消息时，回复文本显示 HTML

**URL:** https://meta.discourse.org/t/reply-text-displays-html-when-replying-to-a-message-that-starts-with-a-mention/257269
**Category:** Bug
**Tags:** chat
**Created:** [2023年三月6日 16:35 UTC](https://meta.discourse.org/t/reply-text-displays-html-when-replying-to-a-message-that-starts-with-a-mention/257269 "2023-03-06T16:35:34Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![simon\_tomes](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon_tomes/32/457537_2.png) [@simon\_tomes](https://meta.discourse.org/u/simon_tomes)
#### Post date: [2023年三月6日 16:35 UTC](https://meta.discourse.org/t/reply-text-displays-html-when-replying-to-a-message-that-starts-with-a-mention/257269/1 "2023-03-06T16:35:34Z")

</div>

当有人回复以提及开头的消息时，它会将 HTML 显示为该回复的一部分。

 ![回复以提及开头的消息时会显示 HTML](https://global.discourse-cdn.com/meta/original/4X/6/3/3/633af042f94d6f7eba53d855a543fafc27e85bc8.png)

例如，请注意回复中的 `\u003ca class=\"mention\" href=\"/u/simon_tomes\"\u003e@simon_tomes\u003c/a\u003e` 部分。

我希望它只显示“@simon_tomes”，然后是原始消息的其余部分。

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [2023年三月6日 16:59 UTC](https://meta.discourse.org/t/reply-text-displays-html-when-replying-to-a-message-that-starts-with-a-mention/257269/3 "2023-03-06T16:59:07Z")

</div>

Simon，感谢你的报告！我们的代码巫师正在处理 🧙

---

<div class="post-metadata">

### Author: ![simon\_tomes](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon_tomes/32/457537_2.png) [@simon\_tomes](https://meta.discourse.org/u/simon_tomes)
#### Post date: [2023年三月6日 16:59 UTC](https://meta.discourse.org/t/reply-text-displays-html-when-replying-to-a-message-that-starts-with-a-mention/257269/4 "2023-03-06T16:59:50Z")

</div>

太棒了，谢谢！Go Code Wizards！🧙

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [2023年四月15日 13:06 UTC](https://meta.discourse.org/t/reply-text-displays-html-when-replying-to-a-message-that-starts-with-a-mention/257269/6 "2023-04-15T13:06:03Z")

</div>

您好，是的，我们正专注于为话题（threads）提供良好的支持，之后会对此进行改进，这100%在我们的路线图中。

---

<div class="post-metadata">

### Author: ![Firepup650](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/firepup650/32/465200_2.png) [@Firepup650](https://meta.discourse.org/u/Firepup650)
#### Post date: [2023年六月30日 18:55 UTC](https://meta.discourse.org/t/reply-text-displays-html-when-replying-to-a-message-that-starts-with-a-mention/257269/7 "2023-06-30T18:55:42Z")

</div>

在聊天中，如果您提及某人，请在提及消息之间至少留一条消息，然后让其他人（或您自己）回复该提及消息，回复将显示类似 `\u003ca class=\"mention\" href=\"/u/firepup650\"\u003e@Firepup650\u003c/a\u003e` 而不是提及。在消息中包含 `\u003c` 和/或 `\u003e` 将会变成 `\u0026lt;` 和 `\u0026gt;`。这似乎是一个最近的更改，而且似乎有些意外，因为如果您的消息只是一个提及，它会正常工作，但消息中的任何其他文本都会导致它在回复中变成 HTML。

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [2023年六月30日 19:22 UTC](https://meta.discourse.org/t/reply-text-displays-html-when-replying-to-a-message-that-starts-with-a-mention/257269/8 "2023-06-30T19:22:37Z")

</div>

我觉得这和这个开放 #Contribute > Bug 主题是一样的 @Firepup650，所以我把你的帖子移到这里来，以便将报告归为一类。 👍

---

<div class="post-metadata">

### Author: ![Firepup650](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/firepup650/32/465200_2.png) [@Firepup650](https://meta.discourse.org/u/Firepup650)
#### Post date: [2023年六月30日 19:33 UTC](https://meta.discourse.org/t/reply-text-displays-html-when-replying-to-a-message-that-starts-with-a-mention/257269/9 "2023-06-30T19:33:07Z")

</div>

此规则似乎也适用于提及不在消息开头的情况，并且也适用于群组提及。

---

<div class="post-metadata">

### Author: ![simon\_tomes](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon_tomes/32/457537_2.png) [@simon\_tomes](https://meta.discourse.org/u/simon_tomes)
#### Post date: [2023年七月5日 15:49 UTC](https://meta.discourse.org/t/reply-text-displays-html-when-replying-to-a-message-that-starts-with-a-mention/257269/10 "2023-07-05T15:49:29Z")

</div>

这个似乎有所回退。我刚刚发现了一条包含 HTML 的回复。

 ![Screenshot 2023-07-05 at 16.47.23](https://global.discourse-cdn.com/meta/original/4X/4/9/3/493aacbf2901e0a1533c6830655e170fbf0ae770.png)

---

<div class="post-metadata">

### Author: ![martin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/martin/32/491371_2.png) [@martin](https://meta.discourse.org/u/martin)
#### Post date: [2023年七月12日 23:45 UTC](https://meta.discourse.org/t/reply-text-displays-html-when-replying-to-a-message-that-starts-with-a-mention/257269/12 "2023-07-12T23:45:10Z")

</div>

感谢您的报告，此问题将在以下提交中修复：

> <https://github.com/discourse/discourse/pull/22559>
>
> Followup to 58c8f91d9acf20bbd8d4ef3bd88ed719564769ec
> 
> It is now safe to render… the message excerpt as HTML since
> it is no longer using text\_entities: true in the server
> PrettyText.excerpt call when creating the message excerpt
> from the cooked HTML.
> 
> This will fix the issue of things like mentions showing
> HTML code instead of the actual mention when replying,
> and cannot be used to inject improper HTML like style tags
> via XSS.
> 
> \<img width="1108" alt="image" src="https://github.com/discourse/discourse/assets/920448/14401f44-70a4-4501-8bb8-8c3b3e386e30"\>

---

<div class="post-metadata">

### Author: ![martin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/martin/32/491371_2.png) [@martin](https://meta.discourse.org/u/martin)
#### Post date: [2023年七月14日 06:47 UTC](https://meta.discourse.org/t/reply-text-displays-html-when-replying-to-a-message-that-starts-with-a-mention/257269/13 "2023-07-14T06:47:22Z")

</div>


