koishijs / webui

WebUI plugins for Koishi
https://koishi.online
GNU Affero General Public License v3.0
29 stars 14 forks source link

BUG:sandbox中&被转换成&传递到command参数中 #195

Closed HuanLinOTO closed 11 months ago

HuanLinOTO commented 1 year ago

标题不太顺,但是看图就懂了

Cache_-6ea4c24b3e13113f

参数标注为text,报错来自别的地方

CyanChanges commented 1 year ago

Sandbox 的输入框用的是 @koishijs/client 的 ChatInput image https://github.com/koishijs/webui/blob/main/packages/components/client/chat/input.vue#L39 当你发送消息的时候会发送 escape 过的 value

image https://github.com/satorijs/satori/blob/master/packages/element/src/index.ts#L119 然后 escape 把 & 换成 &

CyanChanges commented 1 year ago

image https://github.com/koishijs/webui/blob/main/plugins/sandbox/client/layout.vue#L149

然后发送消息,直接发送给后端

image https://github.com/koishijs/webui/blob/main/plugins/sandbox/src/index.ts#L93 这边也没有 unescape, 然后就这么收到了未 unescape 过的消息

HuanLinOTO commented 1 year ago

还有一点是,↑ ↓ 键切换上下文中也有这个问题

CyanChanges commented 1 year ago

image https://github.com/koishijs/webui/blob/main/plugins/sandbox/src/index.ts#L100

续之前,后端收到消息 (未 unescape) 之后会发送一个 sandbox/message 给前端

image https://github.com/koishijs/webui/blob/main/plugins/sandbox/client/utils.ts#L40

前端接收到消息之后就会把存储消息 (未 unescape) 到 @koishijs/client 的存储 (useLocalStorage of @vueuse/core)

image https://github.com/koishijs/webui/blob/main/plugins/sandbox/client/layout.vue#L111

当你使用上下切换之前的消息 (也是未 unescape) 时,读取存储的消息 (未 unescape),于是你就会看到: 你输入的 & (还有其他被 escape 的字符) 全变成 & 了 由于 & 中也有 &
你可以继续 发送(Enter),上一个(UpArrow),无限循环,这个消息长度就会一直增加 ( image

整个过程只有 escape, 没有 unescape, 最终导致了悲剧的发生 (bushi

CyanChanges commented 1 year ago

pr 了 #197

CyanChanges commented 1 year ago

emmm 是不是有点久

CyanChanges commented 1 year ago

好了速通了 【速通 Koishi!-哔哩哔哩】 https://b23.tv/v9c6AYL View now Screenshot_2023-07-26-14-36-20-408_com tencent mobileqq-edit

CyanChanges commented 11 months ago

6,终于修了

shigma commented 11 months ago

这个问题可以被拆分为两个问题:

  1. 按下 ↑ 时的错误转义
  2. text 类型没有被反转义

后一个问题将会在 koishi 仓库中修复。