Unicode 类别 slug 导致 404 错误

它在我的生产实例和开发实例上都会发生。

复现步骤:

  1. 更改或创建一个带有 Unicode slug 的分类
  2. 尝试编辑该分类的设置
  3. 你会收到一个 404 错误

http://localhost:4200/c/测试/find_by_slug.json 的返回结果:

{
"errors": [
"请求的 URL 或资源未找到。"
],
"error_type": "not_found",
"extras": {
"html": "<div class=\"page-not-found\">\n  <h1 class=\"title\">哎呀!该页面不存在或为私密页面。</h1>\n\n\n</div>\n\n\n\n<div class=\"row page-not-found-topics\">\n    <div class=\"recent-topics\">\n      <h2 class=\"recent-topics-title\">最近</h2>\n        <div class='not-found-topic'>\n          <a href=\"/t/welcome-to-discourse/7\">欢迎来到 Discourse</a>\n        </div>\n      <a href=\"/latest\" class=\"btn btn-default\">更多&hellip;</a>\n    </div>\n</div>\n\n\n  <div class=\"row\">\n    <div class=\"page-not-found-search\">\n      <h2>搜索本站</h2>\n      <p>\n        <form action='/search' id='discourse-search'>\n          <input type=\"text\" name=\"q\" value=\"\">\n          <button class=\"btn btn-primary\">搜索</button>\n        </form>\n      </p>\n    </div>\n  </div>\n\n  <link rel=\"preload\" href=\"/assets/onpopstate-handler.js?1621234483.753622\" as=\"script\">\n<script src=\"/assets/onpopstate-handler.js?1621234483.753622\"></script>\n\n"
}
}

附加信息:

  • 设置 unicode usernames(Unicode 用户名)已禁用
  • 即使启用 unicode usernames 问题依然存在
  • allowed unicode username characters(允许的 Unicode 用户名字符) = \p{Han}

将“slug 生成方法”设置更改为“编码”解决了问题,但我不希望我们的主题 URL 使用编码后的 slug。

1 个赞