From 2b58eece509c22a692f4de2512ec41c00e1d2728 Mon Sep 17 00:00:00 2001 From: Vincent Deffontaines Date: Tue, 18 Mar 2025 22:11:27 +0100 Subject: Add webp support --- tests/data/dirty.webp | Bin 0 -> 38502 bytes tests/test_climat2.py | 5 +++++ tests/test_libmat2.py | 10 ++++++++++ tests/test_lightweight_cleaning.py | 5 +++++ 4 files changed, 20 insertions(+) create mode 100644 tests/data/dirty.webp (limited to 'tests') diff --git a/tests/data/dirty.webp b/tests/data/dirty.webp new file mode 100644 index 0000000..0d0e42c Binary files /dev/null and b/tests/data/dirty.webp differ diff --git a/tests/test_climat2.py b/tests/test_climat2.py index 9238253..edc8e88 100644 --- a/tests/test_climat2.py +++ b/tests/test_climat2.py @@ -236,6 +236,11 @@ class TestGetMeta(unittest.TestCase): self.assertIn(b'i am a : various comment', stdout) self.assertIn(b'artist: jvoisin', stdout) + def test_webp(self): + proc = subprocess.Popen(mat2_binary + ['--show', './tests/data/dirty.webp'], + stdout=subprocess.PIPE) + stdout, _ = proc.communicate() + self.assertIn(b'Warning: [minor] Improper EXIF header', stdout) class TestControlCharInjection(unittest.TestCase): def test_jpg(self): diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index 1925201..332a5a3 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py @@ -113,6 +113,11 @@ class TestGetMeta(unittest.TestCase): meta = p.get_meta() self.assertEqual(meta['Comment'], 'Created with GIMP') + def test_webp(self): + p = images.WEBPParser('./tests/data/dirty.webp') + meta = p.get_meta() + self.assertEqual(meta['Warning'], '[minor] Improper EXIF header') + def test_ppm(self): p = images.PPMParser('./tests/data/dirty.ppm') meta = p.get_meta() @@ -333,6 +338,11 @@ class TestCleaning(unittest.TestCase): 'parser': images.JPGParser, 'meta': {'Comment': 'Created with GIMP'}, 'expected_meta': {}, + }, { + 'name': 'webp', + 'parser': images.WEBPParser, + 'meta': {'Warning': '[minor] Improper EXIF header'}, + 'expected_meta': {}, }, { 'name': 'wav', 'parser': audio.WAVParser, diff --git a/tests/test_lightweight_cleaning.py b/tests/test_lightweight_cleaning.py index ce7e48c..9b33df4 100644 --- a/tests/test_lightweight_cleaning.py +++ b/tests/test_lightweight_cleaning.py @@ -23,6 +23,11 @@ class TestLightWeightCleaning(unittest.TestCase): 'parser': images.JPGParser, 'meta': {'Comment': 'Created with GIMP'}, 'expected_meta': {}, + }, { + 'name': 'webp', + 'parser': images.WEBPParser, + 'meta': {'Warning': '[minor] Improper EXIF header'}, + 'expected_meta': {}, }, { 'name': 'torrent', 'parser': torrent.TorrentParser, -- cgit v1.3