From e9b9e93dccfe50429fad83cca0c63ff29addeced Mon Sep 17 00:00:00 2001
From: FredApps <153173854+FredApps@users.noreply.github.com>
Date: Mon, 16 Nov 2026 08:54:03 +0100
Subject: [PATCH] fix(codecs): Place still refuses a header-only image within
the allowance
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
decode_within mapped every LimitExceeded to Ok(None) ("oversized, accept
unread"). craft-image-codecs raises that for its decompression-bomb guard
when a tiny file declares a large image, so Place accepted a header-only
23,170² gray PNG instead of reporting that its pixels can't be read.
Ok(None) now only when the header says the image would take more than the
allowance as samples or as RGBA. A decode that hits a limit stays an error.
---
crates/doc/src/decode.rs | 11 ++++-------
crates/doc/src/links.rs | 39 ++++++++++++++++++++++++++++++++++++---
2 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/crates/doc/src/decode.rs b/crates/doc/src/decode.rs
index 24dea325f7..11d1b2d72b 100644
--- a/crates/doc/src/decode.rs
+++ b/crates/doc/src/decode.rs
@@ -23,8 +23,9 @@ pub fn decode_image(format: craft_image_codecs::Format, bytes: &[u8], allowance:
/// `bytes` decoded within `max` bytes, counted as the file's samples and as RGBA (#1717), the
/// pixels as stored and as the image crate gave them, with the ICC profile the file embeds.
/// Image blobs read their pixels with it. `Ok(None)` when they would take more than `max` as
-/// samples or as RGBA, or when the decode needs more than `max`. `Err` when the bytes aren't an
-/// image the decoder reads.
+/// samples or as RGBA (the header alone decides; the pixels are not read). `Err` when the bytes
+/// aren't an image the decoder reads, including a file whose header fits the allowance but whose
+/// pixels can't be decoded (a cut-short file, or one the decoder refuses as a decompression bomb).
pub fn decode_within(bytes: &[u8], max: u64) -> Result