mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-03 12:35:48 -05:00
Keep one regression for oversized image headers
This commit is contained in:
1 parent
3fa02146d0
commit
7481fd3af8
1 file changed
-12
@@ -478,18 +478,6 @@ mod tests {
|
|||||||
use vectorcraft_doc::{Document, ImageBlob, ImageObject};
|
use vectorcraft_doc::{Document, ImageBlob, ImageObject};
|
||||||
use vectorcraft_geom::Affine;
|
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]
|
#[test]
|
||||||
fn an_image_whose_header_declares_far_more_pixels_than_the_app_reads_is_left_out() {
|
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.
|
// 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