mirror of
https://github.com/lexmount/moli.git
synced 2026-11-22 16:02:34 +00:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user