nathank
(Nathan Kershaw)
Junho 10, 2026, 3:14am
1
Estou percebendo que clicar no link do PDF quando a pré-visualização do PDF está ativa atualmente tenta baixar o PDF (indesejado) em vez de abri-lo em uma nova aba.
Isso ocorre em um ambiente de auto-hospedagem simples (único contêiner, sem CDN, sem S3).
Tudo isso foi abordado anteriormente aqui:
david:
Isso deve ter sido resolvido desde SECURITY: Download allowlist for uploaded files · discourse/discourse@9c0642a · GitHub
Agora temos uma lógica centralizada para determinar quais arquivos devem ser exibidos „inline“. Isso significa que os PDFs são exibidos consistentemente de forma inline, e alguns tipos de arquivo menos seguros são servidos consistentemente como downloads. Essas alterações devem funcionar em todos os tipos de armazenamento de upload (local e S3, com ou sem CDNs).
1 curtida
Estávamos sendo inconsistentes com o tipo display dependendo de você estar usando ou não o S3. Isso deve ser corrigido por
main ← fix-inline-safe-uploads-local-store
opened 02:09PM - 10 Jun 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 via `FileStore::S3Store.content_disposition_for`, and it left simple self-hosted (single-container, no S3/CDN) sites unable to open PDFs inline.
The cause was in `UploadsController#send_file_local_upload`: it 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.
This serves inline-safe files with `Content-Disposition: inline` by default, mirroring the S3 store. The `attachment` disposition and the `sandbox;` Content-Security-Policy header are now scoped to the files that are actually forced to download: unsafe types (HTML, SVG, XML, ...) and explicit downloads (`?dl=1`). The redundant `params[:inline]` branch is removed, since inline-safe files are now served inline by default.
(cc @david )
O fato de clicar em um arquivo abrir automaticamente em outra aba é mais uma questão de product .
1 curtida