现象
dsh-better-sidebar 0.18.0 / DSH Desktop(Web GUI)/ Windows 11。打开工作区外 的 .html 文件(如 %TEMP% 下的本地 HTML):
沙箱状态栏显示"沙箱模式:已启用 · 页面无法访问界面数据与本地文件" → 页面正文显示 forbidden;
点击「临时解锁(不安全)」:状态栏变为红色"未沙箱",但页面内容依然是 forbidden ;
点击刷新:回到沙箱模式(解锁态不保留);
结果:工作区外的 HTML 文件永远无法预览 。
根因(代码层面,供排查)
forbidden 来自 host 路径围栏,不是 iframe 沙箱 :HTML 预览走 /html 路由(html-route.ts),工作区外路径被 real-path guard 拒绝(403 + 裸文本 forbidden;api.ts 注释:request-trust fence answers code forbidden with the bare message 'forbidden')。用户打开的文件在会话工作区之外(如 %TEMP%),路由必然拒绝。
「临时解锁」只改 iframe sandbox 属性 :localUnlock → noSandbox(BrowserView.tsx / TextEditor.tsx),不影响 host 读取围栏 ——iframe 解锁后请求同一 /html/... URL 仍被 403,所以页面依旧 forbidden。
解锁态是组件 useState ,不写全局设置(SandboxStatusBar.tsx 注释明示 temporary unlock is component state only… lasts until the surface unmounts),刷新/切 tab 即复位 → 每次刷新都回到沙箱。
三条叠加 = "解锁无效 + 刷新即锁定"的死循环。
期望
「临时解锁」应同时放行该文件在 html 路由的只读读取 (临时白名单:仅当前文件/当前 tab),或提供工作区外文件的只读预览兜底(关联 点击对话中工作区外的文件引用报 403 path is outside workspace,期望降级为只读预览或回退系统打开 #532 / [Feature] Add an option to access files outside the workspace #442 );
临时解锁跨刷新保留(如 sessionStorage 按 tab 持久化),避免"解锁→刷新→锁定"死循环;
或扩展全局设置语义:现有 htmlViewerNoSandbox 只解 iframe 沙箱、不解路径围栏,文档需说明或联动路径放行。
关联
环境 :DSH Desktop 2.0.4 / Windows 11 / dsh-better-sidebar 0.18.0
现象
dsh-better-sidebar0.18.0 / DSH Desktop(Web GUI)/ Windows 11。打开工作区外的.html文件(如%TEMP%下的本地 HTML):forbidden;forbidden;根因(代码层面,供排查)
forbidden来自 host 路径围栏,不是 iframe 沙箱:HTML 预览走/html路由(html-route.ts),工作区外路径被 real-path guard 拒绝(403 + 裸文本forbidden;api.ts注释:request-trust fence answers codeforbiddenwith the bare message 'forbidden')。用户打开的文件在会话工作区之外(如%TEMP%),路由必然拒绝。localUnlock → noSandbox(BrowserView.tsx/TextEditor.tsx),不影响 host 读取围栏——iframe 解锁后请求同一/html/...URL 仍被 403,所以页面依旧forbidden。useState,不写全局设置(SandboxStatusBar.tsx注释明示 temporary unlock is component state only… lasts until the surface unmounts),刷新/切 tab 即复位 → 每次刷新都回到沙箱。三条叠加 = "解锁无效 + 刷新即锁定"的死循环。
期望
htmlViewerNoSandbox只解 iframe 沙箱、不解路径围栏,文档需说明或联动路径放行。关联
环境:DSH Desktop 2.0.4 / Windows 11 / dsh-better-sidebar 0.18.0