nathank
(Nathan Kershaw)
6월 10, 2026, 3:14오전
1
현재, PDF 미리보기가 활성화된 상태에서 PDF 링크를 클릭하면 새 탭에서 PDF를 여는 대신(원치 않는 동작) PDF를 다운로드하려는 시도가 이루어집니다.
이는 단순한 자체 호스팅 환경(단일 컨테이너, CDN 없음, S3 없음, horizon 테마)에서 발생하는 문제입니다.
이 문제는 이전에 여기서 다뤄졌습니다:
이 문제가 발생하는 이유는, 사용자가 인라인 PDF를 전체 창에서 읽기를 원하기 때문입니다. iframe은 상당히 제한적이기 때문입니다. 다운로드하는 것은 불필요하게 번거로운 단계를 추가합니다. 그리고 이미 iframe 내 PDF 뷰어의 도구 막대에 다운로드 버튼이 존재합니다(최소 Chrome에서는 존재합니다).
2개의 좋아요
S3를 사용하는지에 따라 display 타입 처리가 일관되지 않았습니다. 이 문제는
main ← fix-inline-safe-uploads-local-store
merged 05:52PM - 14 Jul 26 UTC
Inline-safe uploads (images, PDFs, audio and video) served from the local
file s… tore were sent with `Content-Disposition: attachment`, so clicking a
PDF link downloaded the file instead of opening it in the browser. This was
inconsistent with the S3 store, which already serves these files inline, and
it left simple self-hosted (single-container, no S3/CDN) sites unable to open
PDFs inline.
`UploadsController#send_file_local_upload` only set the disposition to
`attachment` for unsafe types, and to `inline` when `?inline=1` was passed,
leaving it unset otherwise. Rails' `send_file` defaults an unset disposition
to `attachment`, so inline-safe files fell through to a download.
Inline-safe files are now served with `Content-Disposition: inline` by
default, mirroring the S3 store, while unsafe types (HTML, SVG, XML, ...) and
explicit downloads (`?dl=1`) keep the `attachment` disposition. The redundant
`params[:inline]` branch is removed, since inline-safe files are now inline by
default.
The `Content-Security-Policy: sandbox;` header stays on **every** response as
defense-in-depth: if the `is_inline_safe?` allowlist is ever wrong, the
sandbox forces an opaque origin and disables script execution so a
misclassified file cannot run as a document in our origin. It does not
interfere with inline viewing — `sandbox` sandboxes scripts *inside* the
served file, not the browser's native rendering of it. Chrome's built-in PDF
viewer and Firefox's pdf.js both render sandboxed PDFs identically to
unsandboxed ones, and images/audio/video decode natively regardless.
A spec locks the allowlist invariant by asserting no inline-safe extension
maps to a script-capable content type, so re-adding something like SVG or XML
to the allowlist fails CI instead of becoming a stored XSS.
을 통해 수정되어야 합니다.
(cc @david )
파일을 클릭하면 자동으로 새 탭에서 열리는 것은 더 많은 product 관련 질문입니다.
3개의 좋아요