Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(html-preview): 转义内嵌更新脚本的地址
Dashbd65ec187497
diff --git a/apps/desktop/src/main/file-browser/html-preview.ts b/apps/desktop/src/main/file-browser/html-preview.tsindex b9557d43e7..2c7ebd00c0 100644--- a/apps/desktop/src/main/file-browser/html-preview.ts+++ b/apps/desktop/src/main/file-browser/html-preview.ts@@ -212,7 +212,9 @@ export async function createHtmlPreview(args: HtmlPreviewArgs, source: PreviewSoif (checkEntry) cachedHtml = original;// One same-origin request observes this opening's existing background check.// Fresh pages do not carry the script, so reload never starts a polling loop.- const reload = checkEntry ? `<script>(()=>{const page=location.pathname;addEventListener('load',()=>{fetch(${JSON.stringify(updatePath)},{cache:'no-store'}).then(r=>r.ok?r.json():false).then(changed=>{if(changed&&location.pathname===page)location.reload();}).catch(()=>{});},{once:true});})();</script>` : '';+ // JSON quoting alone does not escape an HTML script closing tag.+ const updateUrl = JSON.stringify(updatePath).replace(/</g, '\\u003c');+ const reload = checkEntry ? `<script>(()=>{const page=location.pathname;addEventListener('load',()=>{fetch(${updateUrl},{cache:'no-store'}).then(r=>r.ok?r.json():false).then(changed=>{if(changed&&location.pathname===page)location.reload();}).catch(()=>{});},{once:true});})();</script>` : '';const guarded = withSnapshotHtmlCsp(html.charCodeAt(0) === 0xfeff? `\uFEFF${reload}${html.slice(1)}` : reload + html);await fs.writeFile(dest, guarded, { encoding: 'utf8', mode: 0o600 });