GLM-5.3 · Balanced
feature-automatically-downsize-large-images-discourse-cursor
Discourse · Ruby · S · 30–99 lines · 3 files
The normal review, with one generalist agent. Judge: Claude Haiku 5.5.
- Gold bugs found
- 3 of 8
- Comments published
- 4
- Comments matching a bug
- 3
- Comments not matching
- 1
- Cost of this PR
- $0.801
Published comments (4)
Downsizing loses GIF animation because tempfile path lacks .gif extension — Animated GIFs are silently flattened to one frame: `OptimizedImage#optimize` detects animation only when the source path matches `/\.GIF$/i`, which the extensionless multipart tempfile never does, so `allow_animation` is ignored. Downsize from a tempfile carrying the original extension, as `OptimizedImage.create_for` does, or match on the original filename.
Hardcoded 10MB limit drops per-type site setting checks in client validation — Attachments above `max_attachment_size_kb` now pass client-side and fail only after a full upload, and sites configured above 10MB reject valid files, because `maxSizeKB` drops the per-type setting lookup. Restore the settings-driven limit for attachments, keeping the 10MB cap for images only; the 413 handler repeats this hardcode.
Duplicate downsize definition shadows 5-arg version, breaking ResizeEmoji — Every custom-emoji upload now fails its `Jobs::ResizeEmoji` job with `ArgumentError` (5 for 4), leaving the emoji un-downsized: the second `downsize` definition takes only 4 parameters and shadows the original. Keep one signature accepting both the width/height form and the dimensions string.
Unvalidated downsize loop exposes ImageMagick to decompression bombs and banned types — Any logged-in user can force up to five full ImageMagick decode/re-encode passes on a 10MB file with huge pixel dimensions, since the downsize loop runs before size and `authorized_extensions` validation and gates only on `FileHelper.is_image?(filename)`. Downsize only after those checks pass, and cap accepted pixel area first.