mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-02 14:51:20 -05:00
Keep one regression for oversized image headers
This commit is contained in:
@@ -478,18 +478,6 @@ mod tests {
|
||||
use vectorcraft_doc::{Document, ImageBlob, ImageObject};
|
||||
use vectorcraft_geom::Affine;
|
||||
|
||||
#[test]
|
||||
fn an_image_whose_header_declares_far_more_pixels_than_the_app_reads_is_left_out() {
|
||||
// A real 8 × 8 PNG whose IHDR (width, height at 16..24) claims 65535 × 65535, with its CRC fixed.
|
||||
let mut png = vec![];
|
||||
image::DynamicImage::ImageRgb8(image::RgbImage::new(8, 8)).write_to(&mut std::io::Cursor::new(&mut png), image::ImageFormat::Png).unwrap();
|
||||
png[16..24].copy_from_slice(&[0, 0, 0xFF, 0xFF, 0, 0, 0xFF, 0xFF]);
|
||||
let crc =
|
||||
!png[12..29].iter().fold(!0u32, |c, b| (0..8).fold(c ^ u32::from(*b), |c, _| if c & 1 == 1 { 0xEDB8_8320 ^ (c >> 1) } else { c >> 1 }));
|
||||
png[29..33].copy_from_slice(&crc.to_be_bytes());
|
||||
assert!(super::embed(&ImageBlob::png(png), false, true, super::SourceProfiles::Keep).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_image_whose_header_declares_far_more_pixels_than_the_app_reads_is_left_out() {
|
||||
// A real 8 × 8 PNG whose IHDR (width, height at 16..24) claims 65535 × 65535, with its CRC fixed.
|
||||
|
||||
Reference in New Issue
Block a user