fix(images): load valid images from HTTP error responses

Use MIME and image bytes to determine decode eligibility instead of
requiring an HTTP 2xx status. Keep upstream request security checks and
origin cleanliness unchanged.

Cover valid raster and SVG bodies at error statuses and rejection of
empty or malformed image data through the shared parkable image path.
This commit is contained in:
ldm0
2026-11-03 18:08:15 +08:00
parent ea4ed12f29
commit de528c992b
+9 -2
View File
@@ -545,11 +545,18 @@ mod tests {
headers.clone(),
String::new(),
);
let descriptor = image_response_descriptor_from_parkable(&response, &encoded, true)
for origin_clean in [false, true] {
let descriptor = image_response_descriptor_from_parkable(
&response,
&encoded,
origin_clean,
)
.unwrap_or_else(|| {
panic!("{mime} image rejected at HTTP {status}, nosniff={nosniff}")
});
assert_eq!((descriptor.width, descriptor.height), (2, 1));
assert_eq!((descriptor.width, descriptor.height), (2, 1));
assert_eq!(descriptor.origin_clean, origin_clean);
}
}
}
}