From ee4bf7548a51d71f86da006ebc774f40a6965e76 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 5 Aug 2026 18:12:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20delete=20script=20=E2=80=94=20assign=20J?= =?UTF-8?q?SON-safe=20name=20to=20JS=20var,=20no=20\n=20in=20string,=20no?= =?UTF-8?q?=20inline=20concat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/knowledge_bases_list/kb_list.dspy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wwwroot/knowledge_bases_list/kb_list.dspy b/wwwroot/knowledge_bases_list/kb_list.dspy index 4feaa87..c85c8a8 100644 --- a/wwwroot/knowledge_bases_list/kb_list.dspy +++ b/wwwroot/knowledge_bases_list/kb_list.dspy @@ -16,8 +16,7 @@ async with get_sor_context(env, 'rag') as sor: engine = r.embedding_engine or "CLIP" idstr = str(r.id) namestr = r.name or '' - # Escape for JS single-quoted string: backslash, single quote, newline, carriage return - js_name = namestr.replace("\\", "\\\\").replace("'", "\\'").replace("\n", "\\n").replace("\r", "\\r") + safe_name = json.dumps(namestr, ensure_ascii=False) cards.append({ "widgettype": "VBox", "options": {"cwidth": 16, "cheight": 12, "bgcolor": "#f0f7ff", "padding": "12px", @@ -53,7 +52,8 @@ async with get_sor_context(env, 'rag') as sor: "padding": "2px 8px", "borderRadius": "4px", "bgcolor": "#fee"}, "binds": [{"wid": "self", "event": "click", "actiontype": "script", "script": "event.stopPropagation();" - "if(!confirm('\u786e\u8ba4\u5220\u9664\u77e5\u8bc6\u5e93\u300c" + js_name + "\u300d\uff1f\n\n\u8be5\u64cd\u4f5c\u4f1a\u5220\u9664\u77e5\u8bc6\u5e93\u5185\u6240\u6709\u6587\u4ef6\u3001\u6807\u7b7e\u548c\u6570\u636e\uff0c\u4e0d\u53ef\u6062\u590d\uff01'))return;" + "var nm=" + safe_name + ";" + "if(!confirm('\u786e\u8ba4\u5220\u9664\u77e5\u8bc6\u5e93\u300c'+nm+'\u300d\uff1f \u6b64\u64cd\u4f5c\u4e0d\u53ef\u6062\u590d\uff01'))return;" "fetch('/rag/knowledge_bases_list/delete_kb.dspy?kb_id=" + idstr + "').then(function(r){return r.json()}).then(function(d){" "if(d.status==='error'){alert('\u5220\u9664\u5931\u8d25\uff1a'+d.error);return;}" "window.location.href='/rag/knowledge_bases_list/index.ui';"