# 全名中的引号弄乱了引用 markdown

**URL:** <https://meta.discourse.org/t/quotes-in-full-name-mess-up-quote-markdown/391153>\
**Category:** Bug\
**Created:** [2025年十二月12日 15:54 UTC](https://meta.discourse.org/t/quotes-in-full-name-mess-up-quote-markdown/391153 "2025-12-12T15:54:28Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)\
**Post date:** [2025年十二月12日 17:49 UTC](https://meta.discourse.org/t/quotes-in-full-name-mess-up-quote-markdown/391153/4 "2025-12-12T17:49:42Z")

</div>

> [@RGJ](#):
>
> 在 Markdown 中是否有安全的方法来转义引号字符？

恐怕没有 ☹

最简单和最安全的方法是删除它们，虽然不理想，但总比弄坏了要好？🤷‍♂️

> <https://github.com/discourse/discourse/pull/36666>
>
> When "display name on posts" is enabled and "prioritize username in UX" is disab…led, quoting a user with quotation marks in their display name (e.g., \`John "The Dev" Smith\`) breaks the quote markdown:
> 
> \[quote="John "The Dev" Smith, post:1, topic:2"\]
> 
> The BBCode parser's regex \`"(\[^"\]+)"\` stops at the first \`"\` inside the name, capturing only \`John \` instead of the full name.
> 
> Alternatives considered:
> 
> \- Backslash escaping (\`\\"\`): Would require updating the parser regex to support escape sequences and adding unescape logic. Adds complexity and risks breaking existing quotes.
> 
> \- URL encoding (\`%22\`): Requires decoding when rendering. Using \`decodeURIComponent\` on user input creates XSS risk. A safe decoder that only decodes specific characters adds complexity and attack surface for minimal benefit.
> 
> The simplest solution is to strip quotation marks from names when building the quote BBCode. This is safe (no user input decoding), simple (no parser changes), and the minor cosmetic loss in the quote attribution is an acceptable trade-off.
> 
> The \`stripQuotationMarks\` function is defined alongside the existing \`QUOTATION\_MARKS\` array in bbcode-block.js to keep related logic together and avoid duplication.
> 
> Ref - https://meta.discourse.org/t/391153

---

_[View the full topic](https://meta.discourse.org/t/quotes-in-full-name-mess-up-quote-markdown/391153)._
