Kimi K3.1 Pro · 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
- 5 of 8
- Comments published
- 5
- Comments matching a bug
- 5
- Comments not matching
- 0
- Cost of this PR
- $0.885
Published comments (5)
The second `downsize` definition replaces the first one in Ruby, leaving only the… — `Jobs::ResizeEmoji#execute` still calls `OptimizedImage.downsize(path, path, 100, 100, opts)` at app/jobs/regular/resize_emoji.rb:14, so every emoji resize now raises `ArgumentError`; remove the obsolete definition and migrate that caller to `"100x100"`, or preserve the old arity.
Attachment size validation ignores max_attachment_size_kb — The shared validator now applies a 10 MB limit to attachments as well as images, ignoring `max_attachment_size_kb`. Oversized attachments pass client validation only to be rejected by `UploadValidator`, while sites allowing attachments over 10 MB have valid uploads blocked; keep the new image cap but use `Discourse.SiteSettings.max_attachment_size_kb` when `type` is `attachment`.
Animated GIF downsizing passes an invalid percentage to gifsicle — For API-downloaded GIFs, this `"80%"` value reaches `downsize_instructions_animated`, which emits gifsicle `--resize-fit 80%`, but `--resize-fit` requires `WIDTHxHEIGHT` rather than a percentage. Every conversion attempt fails and the oversized animated GIF remains rejected; handle percentage scaling separately, such as with gifsicle's scale option, or pass valid dimensions.
For normal multipart uploads, `tempfile.path` need not retain the original `.gif` extension, but… — A large animated GIF can therefore use `downsize_instructions` and its first-frame-only input, silently flattening the upload despite `allow_animation`; base the choice on the original filename or an explicit GIF flag.
For API URL uploads, attacker-controlled `type` is embedded in the Tempfile prefix on line 55… — A logged-in API caller can place shell metacharacters in `type` and submit an oversized GIF—which previously skipped `fix_image_orientation`—to execute commands, so constrain `type` and invoke the image tools with argument arrays or shell-escaped paths.