nathank
(Nathan Kershaw)
10.Июнь.2026 03:14:15
1
Я обнаружил, что при активном предпросмотре PDF-файла нажатие на ссылку PDF в настоящее время пытается загрузить файл (что нежелательно), вместо того чтобы открыть его в новой вкладке.
Это происходит при простой самостоятельной установке (один контейнер, без CDN, без S3).
Вся эта проблема уже обсуждалась здесь:
david:
Это должно быть исправлено начиная с SECURITY: Download allowlist for uploaded files · discourse/discourse@9c0642a · GitHub
Теперь у нас есть централизованная логика для определения того, какие файлы должны отображаться «встроенно». Это означает, что PDF-файлы последовательно отображаются встроенно, а некоторые менее безопасные типы файлов последовательно предоставляются для загрузки. Эти изменения должны работать со всеми типами хранилищ загружаемых файлов (локальное и S3, с CDN и без).
1 лайк
Мы действовали непоследовательно с типом display в зависимости от того, используете ли вы S3 или нет. Это должно быть исправлено в
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.
(копию @david )
Тот факт, что при клике на файл он открывается автоматически в новой вкладке, скорее относится к вопросу product .
1 лайк