From b47a22b51f2f05e9925b637f2e6b31a36637b00e Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Sun, 11 Jun 2023 15:36:47 +0800 Subject: [PATCH] fix: fix problem on bbcode value maybe include space --- .../web/plugins/com.msgbyte.bbcode/src/bbcode/parser.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/web/plugins/com.msgbyte.bbcode/src/bbcode/parser.tsx b/client/web/plugins/com.msgbyte.bbcode/src/bbcode/parser.tsx index f22ed58b..3d434a46 100644 --- a/client/web/plugins/com.msgbyte.bbcode/src/bbcode/parser.tsx +++ b/client/web/plugins/com.msgbyte.bbcode/src/bbcode/parser.tsx @@ -79,10 +79,13 @@ class BBCodeParser { const { tag, content, attrs } = node; const attrsStr = _toPairs(attrs) .map(([key, value]) => { + /** + * 增加双引号以解决value中可能会出现空格的问题 + */ if (key === value) { - return `=${value}`; + return `="${value}"`; } else { - return ` ${key}=${value}`; + return ` ${key}="${value}"`; } }) // NOTICE: 这里排序看起来好像有问题,但是attrs的顺序是有序的,所以没有问题 @@ -135,6 +138,7 @@ class BBCodeParser { } render(input: string): ReactNode[] { + console.log('input', input); const ast = this.parse(input); return ast