# 发送以下标题的私信会导致错误！

**URL:** <https://meta.discourse.org/t/sending-a-pm-with-the-following-title-causes-an-error/135654>\
**Category:** Bug\
**Created:** [2019年十二月11日 13:46 UTC](https://meta.discourse.org/t/sending-a-pm-with-the-following-title-causes-an-error/135654 "2019-12-11T13:46:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![WorldIsMine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/worldismine/32/455660_2.png) [@WorldIsMine](https://meta.discourse.org/u/WorldIsMine)\
**Post date:** [2019年十二月11日 13:46 UTC](https://meta.discourse.org/t/sending-a-pm-with-the-following-title-causes-an-error/135654/1 "2019-12-11T13:46:36Z")

</div>

我在给一位用户撰写新消息时，没时间写个正常的标题，于是随便敲了一通键盘，把下面这串字符当作了标题：

> =213=-!(@#+@)(!\*\_(@#&(!)#

收到消息的用户点击后，却看到“无法访问该页面”的提示。  
在我这边，网站则把我重定向到一条随机的系统对用户消息。

我尝试在 Meta 上复现这个问题：当我发送消息时，被重定向到了“哎呀，此页面不存在”的提示。

所以，确实出了点问题，但我不清楚原因。那串字符中的某些内容触发了一个漏洞。

---

<div class="post-metadata">

**Author:** ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)\
**Post date:** [2019年十二月11日 23:18 UTC](https://meta.discourse.org/t/sending-a-pm-with-the-following-title-causes-an-error/135654/2 "2019-12-11T23:18:35Z")

</div>

将这样一个标题引发的问题视为干扰正常使用的漏洞，似乎有些牵强。

> [@WorldIsMine](#):
>
> 该字符串中的某些内容导致了漏洞。

无论这是否属于人为构造的极端情况，确定实际问题所在都是个好主意。

我不建议使用 meta 进行测试，你的开发环境才是测试的正确场所。无论如何，我猜测是哈希值引发了某种片段标识符冲突。如果你尝试去掉 “#” 后再次测试，问题是否依然存在？

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2019年十二月11日 23:26 UTC](https://meta.discourse.org/t/sending-a-pm-with-the-following-title-causes-an-error/135654/3 "2019-12-11T23:26:35Z")

</div>

是的，这里有些不对劲。由于 slug 看起来像数字，导致该主题被错误地重定向到了主题 213。

我们应该修复这个问题。看起来要么是 slug 的 bug，要么是路由的 bug。

@Martin_Brennan 你能看一下吗？

---

<div class="post-metadata">

**Author:** ![WorldIsMine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/worldismine/32/455660_2.png) [@WorldIsMine](https://meta.discourse.org/u/WorldIsMine)\
**Post date:** [2019年十二月12日 07:46 UTC](https://meta.discourse.org/t/sending-a-pm-with-the-following-title-causes-an-error/135654/7 "2019-12-12T07:46:22Z")

</div>

> [@Mittineague](#):
>
> 把一个像这样的标题引发的问题视为干扰正常使用的漏洞，感觉有些牵强。

天哪，那就请给我一个您满意的标题吧。我会修改它。

---

<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:** [2019年十二月17日 00:51 UTC](https://meta.discourse.org/t/sending-a-pm-with-the-following-title-causes-an-error/135654/9 "2019-12-17T00:51:28Z")

</div>

这已根据 [FIX: If a prettified slug is a number, return default by martin-brennan · Pull Request #8554 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/8554) 修复。我们对待最终简化为数字的标题的方式，与直接将数字 213 作为话题标题时完全相同。

---

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [2019年十二月19日 02:00 UTC](https://meta.discourse.org/t/sending-a-pm-with-the-following-title-causes-an-error/135654/10 "2019-12-19T02:00:00Z")

</div>

此主题在 43 小时后自动关闭。不再允许新回复。
