walinejs / waline

💬 A Simple, Safe Comment System
https://waline.js.org/en/
GNU General Public License v2.0
2.19k stars 379 forks source link

[BUG] 数学公式中的错误语法会导致整个评论区崩溃 #262

Closed HEIGE-PCloud closed 3 years ago

HEIGE-PCloud commented 3 years ago

问题描述 | Describe the bug

在评论区中输入数学公式

Euler’s identity $e^{i\pi}+1=0$ is a beautiful formula in $\mathbb{R}^2$.

$$
\frac {\partial^r} {\partial \omega^r} \left(\frac {y^{\omega}} {\omega}\right)
= \left(\frac {y^{\omega}} {\omega}\right) \left\{(\log y)^r + \sum_{i=1}^r \frac {(-1)^i r \cdots (r-i+1) (\log y)^{r-i}} {\omega^i} \right\}
$$

来源:https://waline.js.org/syntax.html#%E6%95%B0%E5%AD%A6%E5%85%AC%E5%BC%8F

image

弹出对话框报错。再次刷新页面后评论区无法显示。

问题网站 | Website URL

https://waline.js.org/

image

HEIGE-PCloud commented 3 years ago

但是这个公式的语法本身是正确的,也可以用KaTeX正确渲染。 image

并且看 #58 数学公式渲染上的问题还蛮多的,比如并不支持$...$,行内渲染得通过$$...$$触发。但这个bug是比较恶性的,可以使得整个评论区崩溃。

Mister-Hope commented 3 years ago

@lizheming 这个锅..... 不在我身上吧。 官网的服务器升级到最新的server了么?

Mister-Hope commented 3 years ago

image

本地测试最新的server未复现官网的错误。

Mister-Hope commented 3 years ago

已确认,感谢汇报 @HEIGE-PCloud

0.23.x 存在此问题 (配合任何版本的客户端) 这是因为没有显式为 katax 设置 throwonError:false 的问题。同时 0.23.x 版本还存在正则表达式的匹配问题导致katex会接收到错误的表达式。

throwOnError: boolean. If true (the default), KaTeX will throw a ParseError when it encounters an unsupported command or invalid LaTeX. If false, KaTeX will render unsupported commands as text, and render invalid LaTeX as its source code with hover text giving the error, in the color given by errorColor.

此问题应该不存在于最新的 0.24.0 中。等待 @lizheming 重新使用最新依赖部署官网即可解决。

Mister-Hope commented 3 years ago

官网评论服务已使用最新依赖重新部署

image