# 部分 Markdown 链接的字符编码不兼容

**URL:** https://meta.discourse.org/t/incompatible-character-encodings-for-some-markdown-links/413290
**Category:** Bug
**Tags:** markdown
**Created:** [2026年九月25日 01:42 UTC](https://meta.discourse.org/t/incompatible-character-encodings-for-some-markdown-links/413290 "2026-09-25T01:42:42Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![lilydjwg](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilydjwg/32/515838_2.png) [@lilydjwg](https://meta.discourse.org/u/lilydjwg)
#### Post date: [2026年九月25日 01:42 UTC](https://meta.discourse.org/t/incompatible-character-encodings-for-some-markdown-links/413290/1 "2026-09-25T01:42:42Z")

</div>

我刚[了解到新的 `.md` 链接支持](https://meta.discourse.org/t/discourse-core-now-includes-markdown-endpoints-for-topic-lists-and-views/413006)，所以在更新到最新版本后，我在自己的网站上尝试了一下，结果有时会出现以下错误：

```plaintext
Encoding::CompatibilityError (incompatible character encodings: UTF-8 and US-ASCII)
lib/markdown_endpoint/topic_renderer.rb:83:in 'MarkdownEndpoint::TopicRenderer#render_post'
lib/markdown_endpoint/topic_renderer.rb:23:in 'block in MarkdownEndpoint::TopicRenderer#render'
lib/markdown_endpoint/topic_renderer.rb:21:in 'Array#each'
lib/markdown_endpoint/topic_renderer.rb:21:in 'Enumerable#each_with_index'
lib/markdown_endpoint/topic_renderer.rb:21:in 'MarkdownEndpoint::TopicRenderer#render'
app/controllers/topics_controller.rb:1592:in 'block (2 levels) in TopicsController#perform_show_response'
app/controllers/topics_controller.rb:1568:in 'TopicsController#perform_show_response'
app/controllers/topics_controller.rb:233:in 'TopicsController#show'
app/controllers/application_controller.rb:458:in 'block in ApplicationController#with_resolved_locale'
app/controllers/application_controller.rb:458:in 'ApplicationController#with_resolved_locale'
app/controllers/application_controller.rb:1140:in 'ApplicationController#ensure_dont_cache_page'
lib/middleware/omniauth_bypass_middleware.rb:35:in 'Middleware::OmniauthBypassMiddleware#call'
lib/middleware/crawler_hooks.rb:13:in 'Middleware::CrawlerHooks#call'
lib/content_security_policy/middleware.rb:12:in 'ContentSecurityPolicy::Middleware#call'
lib/middleware/anonymous_cache.rb:431:in 'Middleware::AnonymousCache#call'
lib/middleware/csp_script_nonce_injector.rb:13:in 'Middleware::CspScriptNonceInjector#call'
lib/middleware/track_view_session_id_injector.rb:12:in 'Middleware::TrackViewSessionIdInjector#call'
config/initializers/008-rack-cors.rb:14:in 'Discourse::Cors#call'
lib/middleware/default_headers.rb:13:in 'Middleware::DefaultHeaders#call'
config/initializers/100-quiet_logger.rb:20:in 'DiscourseRackQuietAssetsLogger#call'
config/initializers/100-silence_logger.rb:29:in 'SilenceLogger#call'
lib/middleware/enforce_hostname.rb:23:in 'Middleware::EnforceHostname#call'
lib/middleware/request_tracker.rb:384:in 'Middleware::RequestT...

```

看起来它不兼容我的非 ASCII 用户名（`依云`）。

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [2026年九月25日 02:24 UTC](https://meta.discourse.org/t/incompatible-character-encodings-for-some-markdown-links/413290/3 "2026-09-25T02:24:44Z")

</div>

感谢反馈，此修复应能解决该问题

> <https://github.com/discourse/discourse/pull/44106>
>
> Previously, Markdown topic endpoints could raise an encoding error for authors w…ith Unicode usernames, as reported \[on Meta\](https://meta.discourse.org/t/413290).
> 
> This change percent-encodes non-ASCII characters in avatar URLs so these topics render correctly, with regression coverage for the reported username.
