fix(webui): support PPT preview and shell open in server mode#1679
fix(webui): support PPT preview and shell open in server mode#1679kaizhou-lab merged 3 commits intomainfrom
Conversation
- Add shellBridgeStandalone using Node.js child_process (open/xdg-open/cmd)
so "open with system app" works in server (non-Electron) mode
- Register shellBridgeStandalone in initBridgeStandalone
- Export isActivePreviewPort and stopAllWatchSessions from pptPreviewBridge
- Add /api/ppt-proxy/:port reverse proxy route in apiRoutes:
- Validates port against active sessions (SSRF prevention)
- Rewrites Location headers (absolute and relative) through the proxy
- Overrides X-Frame-Options to SAMEORIGIN so iframe can load
- Injects a navigation guard script into HTML responses to prevent
officecli page JS from navigating the iframe outside the proxy path
- Update PptViewer to use <iframe> in server mode with proxy URL,
and <WebviewHost> only in Electron mode
Code Review:fix(webui): support PPT preview and shell open in server mode (#1679)变更概述本 PR 为 server(非 Electron)模式新增了两项能力:(1) 方案评估结论:✅ 方案合理 整体方案思路正确:通过 port 白名单校验防止 SSRF、用 Location 重写保证代理透明性、注入 guard script 限制 iframe 导航逸出——三层防护设计合理。 问题清单🟠 HIGH — 非 HTML 流式响应路径缺少
|
| # | 严重级别 | 文件 | 问题 |
|---|---|---|---|
| 1 | 🟠 HIGH | apiRoutes.ts:538 |
非 HTML pipe 路径缺少 proxyRes 错误处理 |
| 2 | 🟡 MEDIUM | apiRoutes.ts:467 |
proxy 请求无超时,可能永久挂起 |
| 3 | 🔵 LOW | apiRoutes.ts:515 |
location.href getter 覆盖返回相对路径 |
| 4 | 🔵 LOW | pptPreviewBridge.ts:277 |
isActivePreviewPort 缺少测试 |
| 5 | 🔵 LOW | shellBridgeStandalone.ts |
新文件缺少单元测试 |
结论
本报告由本地 pr-review skill 生成,包含完整项目上下文,无截断限制。
- Add proxyRes error handler on non-HTML pipe path to prevent uncaught EventEmitter errors from crashing the process - Add 30s timeout to proxy requests with 504 response on timeout - Remove location.href getter override in guard script to avoid breaking pages that rely on window.location.href returning a full URL - Add isActivePreviewPort tests: active port, exited process, stopped session - Add shellBridgeStandalone unit tests covering all three platforms and error handling Review follow-up for #1679
PR Fix 验证报告原始 PR: #1679
总结: ✅ 已修复 5 个 | ❌ 未能修复 0 个 | ⏭️ 跳过 0 个 |
Summary
shellBridgeStandaloneusing Node.jschild_processso "使用系统默认应用打开" works in server (non-Electron) mode/api/ppt-proxy/:portreverse proxy route with Location rewriting,X-Frame-Options: SAMEORIGINoverride, and a navigation guard script injected into HTML responses to prevent the preview page from navigating outside the proxy pathPptViewerto use<iframe>with proxy URL in server mode,<WebviewHost>only in Electron modeTest plan
.pptxfile — preview loads correctly in the iframe<WebviewHost>(no regression)