diff --git a/.changeset/great-math-spoons.md b/.changeset/great-math-spoons.md new file mode 100644 index 0000000000..74e301a442 --- /dev/null +++ b/.changeset/great-math-spoons.md @@ -0,0 +1,5 @@ +--- +"@moonshot-ai/kimi-code": patch +--- + +web: Fix LaTeX formulas rendering as garbled overlapping text when the web UI is accessed over the network; the server's content security policy now allows the inline styles that math and code highlighting rely on, while scripts remain strictly restricted. diff --git a/packages/kap-server/src/middleware/securityHeaders.ts b/packages/kap-server/src/middleware/securityHeaders.ts index 6df53f7502..b1bab92d02 100644 --- a/packages/kap-server/src/middleware/securityHeaders.ts +++ b/packages/kap-server/src/middleware/securityHeaders.ts @@ -20,6 +20,12 @@ * Invariant: the served bundle must contain no inline scripts (guarded * by a kimi-web test), so plain `script-src` falling back to * `default-src 'self'` suffices. + * `style-src` needs 'unsafe-inline': KaTeX math and Shiki highlighting + * are rendered off-thread and injected via innerHTML with per-glyph + * `style="…"` attributes (KaTeX carries ALL vertical/font sizing in + * them — stripping collapses formulas into overlapping glyphs), and + * Mermaid embeds an inline