公网临时链接图片改 inline 返回:点开直接看图,不再一律下载

/p/<id> 原先不分类型一律 attachment(为安卓封装壳的 DownloadManager 兜底),图片外链点开只会进下载器;read_file 读图也走这个端点,用户点开来只能下载、看不到图。

- download-send.js 抽出 contentDisposition(type),新增 inlineImageType / sendInlineImage
- 图片显式给 image/* + X-Content-Type-Options: nosniff + inline;缓存仍 no-store(/p/ 是短命 bearer 链)
- 按扩展名判定:png/jpg/jpeg/webp/gif/bmp/tif/tiff/avif/ico/svg,不读文件头做嗅探
- SVG 额外加 CSP: sandbox(匿名同源端点,直接打开不能执行内嵌脚本;img 引用不受影响)
- inline 走 dotfiles:allow,保证 read_file 的 .imgcache/ 压缩产物能取到
- 其余类型(PDF/Office/zip/HTML 等)保持 attachment,下载语义与安卓兜底不变
- README「公网临时链接」补响应头说明
This commit is contained in:
2026-11-11 07:31:02 +08:00
parent b0a8283406
commit 3806071698
3 changed files with 61 additions and 7 deletions
+1
View File
@@ -360,6 +360,7 @@ http://<host>/p/<id>
- 只由 core 进程内的工具签发,签发前校验文件在任务目录内且 `realpath` 未越界。
- 默认 30 分钟过期,可配置 1 分钟到 24 小时。
- 链接可重复使用,直到过期;服务重启后全部失效。
- 响应头按类型分开:图片(`png/jpg/webp/gif/bmp/tif/avif/ico/svg`)返回 `inline` + 对应 `image/*`,点开链接直接看图;其余类型返回 `attachment`,交给浏览器/WebView 下载(SVG 额外带 `Content-Security-Policy: sandbox`,禁止内嵌脚本)。
- 任何人拿到链接即可匿名访问,不要对含密钥的文件签发。
### HTTPS