# 在频道名称中有右括号会破坏该频道的所有引用

**URL:** <https://meta.discourse.org/t/having-a-right-bracket-in-a-channel-name-breaks-all-quotes-from-that-channel/308439>\
**Category:** Bug\
**Tags:** chat, fixed\
**Created:** [2024年五月17日 15:09 UTC](https://meta.discourse.org/t/having-a-right-bracket-in-a-channel-name-breaks-all-quotes-from-that-channel/308439 "2024-05-17T15:09:31Z")\
**Posts on this page:** 5\
**Page:** 1

<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:** [2024年五月17日 15:09 UTC](https://meta.discourse.org/t/having-a-right-bracket-in-a-channel-name-breaks-all-quotes-from-that-channel/308439/1 "2024-05-17T15:09:32Z")

</div>

示例，附带虚假频道数据：

Someone random

#Some cool channel
#Some cool channel

此引用工作正常

Someone random

#[Some cool channel]
#[Some cool channel]

此引用无法正常工作

---

<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:** [2024年五月24日 08:57 UTC](https://meta.discourse.org/t/having-a-right-bracket-in-a-channel-name-breaks-all-quotes-from-that-channel/308439/7 "2024-05-24T08:57:56Z")

</div>

感谢您的报告 @Firepup650 👍  
我想是时候我们终于做了 😅

> <https://github.com/discourse/discourse/blob/c39a4de139ed9bba4696d44b15cb7569038b5fde/app/assets/javascripts/discourse-markdown-it/src/features/bbcode-block.js#L73>

一旦这个 PR 被审查和合并 👇 就会得到修复

> <https://github.com/discourse/discourse/pull/27173>
>
> Wasn't quite handling the cases where a closing bracket \`\]\` was used in the valu…e of one of the attributes.
> 
> \`\`\`markdown
> \[chat quote=user channel="\[broken\]"\]
> \`\`\`
> 
> Would not be correctly parsed because we would \_greedily\_ use the first \`\]\` as the end of the tag even though it might be a valid character when inside proper quotes.
> 
> https://github.com/discourse/discourse/blob/c39a4de139ed9bba4696d44b15cb7569038b5fde/app/assets/javascripts/discourse-markdown-it/src/features/bbcode-block.js#L62
> 
> Re-wrote the \`parseBBCodeTag\` to properly handle the following cases
> 
> \- A closing tag (aka \`\[/name\]\`) which are easy since they don't have any attributes
> \- An old \`\[quote=...\]\` format we used that doesn't uses quotes but still has various attributes of the form \`key:value\`
> \- All three valid BBCode opening tag formats we support
> - \`\[name\]\` without any attributes
> - \`\[name=foo\]\` with a default value
> - \`\[name foo=bar\]\` with some attributes
> 
> Ended up having to fix/rewrite the few bbcode rules that were using the \`parseBBCodeTag\` function, namely \`d-wrap\` and \`discourse-local-dates\`.
> 
> While working on this, I think I also found a way to get rid the of shims we had in place so that plugins could use the \`parseBBCodeTag\` function.
> 
> Reference - https://meta.discourse.org/t/having-a-right-bracket-in-a-channel-name-breaks-all-quotes-from-that-channel/308439

---

<div class="post-metadata">

**Author:** ![Peter\_Baehr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/peter_baehr/32/393699_2.png) [@Peter\_Baehr](https://meta.discourse.org/u/Peter_Baehr)\
**Post date:** [2024年六月4日 16:15 UTC](https://meta.discourse.org/t/having-a-right-bracket-in-a-channel-name-breaks-all-quotes-from-that-channel/308439/10 "2024-06-04T16:15:30Z")

</div>

在发现与文件上传相关的错误后，我遇到了这个错误/修复。如果文件名包含“]”字符但前面没有“[”，它会破坏格式并且不会生成链接。我怀疑在这里修复 BBCode 解析器也能解决该问题，但以防万一在其他地方进行了解析，我还是提到了这一点。

---

<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:** [2024年六月18日 10:38 UTC](https://meta.discourse.org/t/having-a-right-bracket-in-a-channel-name-breaks-all-quotes-from-that-channel/308439/16 "2024-06-18T10:38:52Z")

</div>

PR 已合并，已在此处部署，并且 OP 已重新烘焙 👍

---

<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:** [2024年六月21日 10:43 UTC](https://meta.discourse.org/t/having-a-right-bracket-in-a-channel-name-breaks-all-quotes-from-that-channel/308439/18 "2024-06-21T10:43:53Z")

</div>

此主题已在 3 天后自动关闭。不再允许回复。
