fix(lagoon/attach): store non-inline uploads with Content-Disposition attachment (quick-261028-rqe)

- attach.IsInlineContentType: the shared inline raster list (JPEG, PNG,
  GIF, WebP, AVIF), parameters and case ignored, false for empty or
  unparsable values
- writeBlob stores Content-Disposition: attachment for every other type,
  so a public bucket or CDN makes the browser download HTML, SVG, PDF or
  plain text; content_type and thumbnails are unchanged
- driver tests on memblob and fileblob, Postgres-backed Store assertion,
  lagoon README and the storage and attachments pages
This commit is contained in:
Jakub Zych
2026-10-28 21:10:48 +01:00
parent 61d10436c7
commit ba8432cfb8
8 changed files with 205 additions and 8 deletions

View File

@@ -128,6 +128,14 @@ func TestFileThumbResizesOnce(t *testing.T) {
if url1 != want || url2 != want {
t.Fatalf("urls = %q %q, want %q", url1, url2, want)
}
// Thumbnails stay inline: an image type and no disposition.
attrs, err := bucket.Attributes(ctx, strings.TrimPrefix(url1, "/storage/uploads/"))
if err != nil {
t.Fatalf("thumbnail Attributes: %v", err)
}
if attrs.ContentType != "image/jpeg" || attrs.ContentDisposition != "" {
t.Fatalf("thumbnail attrs = %q %q, want image/jpeg and no disposition", attrs.ContentType, attrs.ContentDisposition)
}
}
func TestFileThumbEncodeFailureDoesNotCache(t *testing.T) {