From e1f0c406acf8207bde02bd7118f90a8ccdce69c3 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 5 Aug 2026 17:15:13 +0800 Subject: [PATCH] fix(kb): escape namestr with json.dumps in delete button JS to prevent SyntaxError Root cause: namestr directly concatenated into JS confirm() string broke when KB name contained quotes or special chars. The SyntaxError prevented event.stopPropagation() from executing, which caused the card click to also fire (navigating to detail.ui). --- wwwroot/knowledge_bases_list/kb_list.dspy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wwwroot/knowledge_bases_list/kb_list.dspy b/wwwroot/knowledge_bases_list/kb_list.dspy index 32914c2..f9682b1 100644 --- a/wwwroot/knowledge_bases_list/kb_list.dspy +++ b/wwwroot/knowledge_bases_list/kb_list.dspy @@ -52,7 +52,7 @@ 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" + namestr + "\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;" + "if(!confirm('\u786e\u8ba4\u5220\u9664\u77e5\u8bc6\u5e93\u300c' + " + json.dumps(namestr, ensure_ascii=False) + " + '\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;" "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';"