Files
eip4-platform/platform-report
zhengwr a6eced0761 feat(report): pdf/xls 导出加 Content-Disposition attachment + 中文文件名
报表查看器 iframe 用 format=html(inline 内嵌);导出按钮用 format=pdf|xls,端点须触发
下载而非内嵌渲染。render() 对 pdf/xls 设 Content-Disposition: attachment;文件名取报表名
(view_template.name,经 RFC5987 filename*=UTF-8'' 编码中文,ASCII 回退 filename="<templateId>.<ext>"
供老客户端);html 不设此头(查看器内嵌不变)。

- ReportTemplateRepository.loadReportName(templateId):取 view_template.name 作文件名,最佳努力
  (找不到/异常返 null → 回退 templateId,绝不因取名失败影响渲染)。
- contentDisposition(fmt,name,templateId)/sanitizeFilename:纯函数。sanitizeFilename 剔除
  CR/LF/引号/反斜杠/正斜杠/控制符,杜绝响应头注入(CRLF 拆头)与 filename 属性逃逸。
  filename* 修正为 RFC5987 attr-char 口径(空格→%20、*→%2A)。
- ReportDownloadTest:5 单测(html 无头/pdf RFC5987 中文名/xls 扩展/注入中和/空名回退 templateId)。

真验(curl):pdf/xls 回 attachment + filename*=UTF-8''在建项目收付款信息表.{pdf,xls};html 无 Content-Disposition。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 23:01:45 +08:00
..