Skip to content

添加静态文件 授信host 功能 防止XSS#747

Open
gaoxingzaq wants to merge 3 commits into
kekingcn:masterfrom
gaoxingzaq:dle
Open

添加静态文件 授信host 功能 防止XSS#747
gaoxingzaq wants to merge 3 commits into
kekingcn:masterfrom
gaoxingzaq:dle

Conversation

@gaoxingzaq
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Contributor

@klboke klboke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

发现 2 个会直接影响现有预览能力的 blocker:

  1. online3D 现在只把“单个 Blob 文件”喂给 viewer,导致依赖伴随资源的多文件格式回归。原实现是把 website/index.html#model=... 交给内置 hash loader 处理,viewer 自己支持 URL 列表和依赖文件(server/src/main/resources/web/online3D.ftl:22-31server/src/main/resources/static/website/build/website_dev/o3dv.website.min.js:9487-9488, 10198, 10371-10381)。这个 PR 改成了先 fetch 一个 modelUrl,再构造单个 File 触发 <input type=file> 流程(server/src/main/resources/web/online3D.ftl:90-133)。这样像 .obj + .mtl + texture 这类依赖同目录附属文件的预览就没有依赖文件上下文了;仓库自带的 3D viewer 示例本身都把 obj 当成多 URL 场景处理(server/src/main/resources/static/website/index.html 里的 #model=assets/models/solids.obj,assets/models/solids.mtl)。也就是说,这个改动会把现有一类 3D 预览直接打坏。

  2. drawio 的编辑/新窗口路径现在会打开错误的文件来源。drawio.ftl 仍然显式传了 edit=_blank,所以预览页工具栏上的 edit/open 路径还在(server/src/main/resources/web/drawio.ftl:47-61)。但这个 PR 把 vendor bundle 里的 Editor.prototype.editAsNew 改成了固定写入 file=<currentDomain>,而不是当前图文件 URL(server/src/main/resources/static/drawio/js/app.min.js:2467-2468)。同一个 bundle 里 chromeless toolbar 的 edit 按钮会直接走 editAsNew(...)server/src/main/resources/static/drawio/js/app.min.js:2578-2581)。结果就是用户从预览页点“编辑/新窗口”时,draw.io 会重新对着站点根域名打开,而不是当前 diagram 文件,这条现有交互会失效。

这两个问题都属于合并前需要先修掉的回归。

@gaoxingzaq
Copy link
Copy Markdown
Contributor Author

gaoxingzaq commented Apr 16, 2026

发现 2 个会直接影响现有预览能力的 blocker:

  1. online3D 修复多资源附件问题 添加了附件调用方法https://3dviewer.net/assets/models/solids.mtl,https://3dviewer.net/assets/models/solids.obj
  1. drawio 修复drawio文件 编辑模式edit 获取file路径错误问题

已经修复了

Copy link
Copy Markdown
Contributor

@klboke klboke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

继续跟进了 4/16 新增的两个提交,之前的 blocker 还不能关闭,当前仍建议保持 changes requested。

  1. drawio.ftl 现在把 iframe hash 写死成了 #Uhttp://127.0.0.1/1.drawio(当前 PR 的 server/src/main/resources/web/drawio.ftl:61)。这样初始预览加载的不是当前 fileUrl,而是固定的本地测试地址;新增的 file= 参数只被后续 editAsNew 逻辑读取,不能替代 draw.io viewer 初始打开文件所用的 #U...。这里应该恢复为基于当前文件地址构造 hash,例如原来的 #U + encodeURIComponent(url) 这一类逻辑,否则普通 drawio 预览会直接打开错文件。

  2. online3D 仍然没有沿用 3D viewer 已有的 hash/URL-list 加载入口。当前 PR 改成自写 fetch -> File -> input change 流程,并尝试调用 OV.Website.ImportFiles/LoadFilesOV.ViewerManager.getViewer()server/src/main/resources/web/online3D.ftl:201-229),但现有 o3dv.website.min.js 对外导出的只有 EngineRegisterHeaderPluginRegisterToolbarPluginSetWebsiteEventHandlerStartEmbedStartWebsiteUI,并没有 OV.WebsiteOV.ViewerManager 这类 API。bundle 内部本来已经有 GetModelFilesFromHash / SetModelFilesToHash / LoadModelFromUrlList,原实现走 website/index.html#model=... 正是交给这条路径处理。现在这套重写绕开了 viewer 的原生 URL-list loader,依赖程序化 file input fallback,风险仍然落在多 URL / OBJ+MTL / texture 这类场景上。

合并前建议先把 drawio 的固定测试 URL 去掉;3D 预览则尽量保留或复用 viewer 的 #model=url1,url2/LoadModelFromUrlList 路径,并补一个实际远程 OBJ+MTL 的烟测,证明多资源附件不是靠手工列几个 URL 才偶然能跑。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants