summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libmat2/harmless.py2
-rw-r--r--libmat2/images.py16
-rw-r--r--tests/test_corrupted_files.py5
-rw-r--r--tests/test_libmat2.py4
4 files changed, 5 insertions, 22 deletions
diff --git a/libmat2/harmless.py b/libmat2/harmless.py
index 9032caf..336873c 100644
--- a/libmat2/harmless.py
+++ b/libmat2/harmless.py
@@ -5,7 +5,7 @@ from . import abstract
5 5
6class HarmlessParser(abstract.AbstractParser): 6class HarmlessParser(abstract.AbstractParser):
7 """ This is the parser for filetypes that do not contain metadata. """ 7 """ This is the parser for filetypes that do not contain metadata. """
8 mimetypes = {'text/plain', } 8 mimetypes = {'text/plain', 'image/x-ms-bmp'}
9 9
10 def get_meta(self) -> Dict[str, str]: 10 def get_meta(self) -> Dict[str, str]:
11 return dict() 11 return dict()
diff --git a/libmat2/images.py b/libmat2/images.py
index 74533b5..311186d 100644
--- a/libmat2/images.py
+++ b/libmat2/images.py
@@ -110,19 +110,3 @@ class TiffParser(GdkPixbufAbstractParser):
110 'FilePermissions', 'FileSize', 'FileType', 110 'FilePermissions', 'FileSize', 'FileType',
111 'FileTypeExtension', 'ImageHeight', 'ImageSize', 111 'FileTypeExtension', 'ImageHeight', 'ImageSize',
112 'ImageWidth', 'MIMEType', 'Megapixels', 'SourceFile'} 112 'ImageWidth', 'MIMEType', 'Megapixels', 'SourceFile'}
113
114
115class BMPParser(GdkPixbufAbstractParser):
116 _type = 'bmp'
117 mimetypes = {'image/x-ms-bmp'}
118 meta_whitelist = {'SourceFile', 'ExifToolVersion', 'FileName', 'Directory',
119 'FileSize', 'FileModifyDate', 'FileAccessDate',
120 'FileInodeChangeDate', 'FilePermissions', 'FileType',
121 'FileTypeExtension', 'MIMEType', 'BMPVersion',
122 'ImageWidth', 'ImageHeight', 'Planes', 'BitDepth',
123 'Compression', 'ImageLength', 'PixelsPerMeterX',
124 'PixelsPerMeterY', 'NumColors', 'NumImportantColors',
125 'RedMask', 'GreenMask', 'BlueMask', 'AlphaMask',
126 'ColorSpace', 'RedEndpoint', 'GreenEndpoint',
127 'BlueEndpoint', 'GammaRed', 'GammaGreen', 'GammaBlue',
128 'ImageSize', 'Megapixels'}
diff --git a/tests/test_corrupted_files.py b/tests/test_corrupted_files.py
index 4b2243d..1beb2ba 100644
--- a/tests/test_corrupted_files.py
+++ b/tests/test_corrupted_files.py
@@ -4,7 +4,7 @@ import unittest
4import shutil 4import shutil
5import os 5import os
6 6
7from libmat2 import pdf, images, audio, office, parser_factory, torrent 7from libmat2 import pdf, images, audio, office, parser_factory, torrent, harmless
8 8
9 9
10class TestUnsupportedFiles(unittest.TestCase): 10class TestUnsupportedFiles(unittest.TestCase):
@@ -65,8 +65,7 @@ class TestCorruptedFiles(unittest.TestCase):
65 65
66 def test_bmp(self): 66 def test_bmp(self):
67 shutil.copy('./tests/data/dirty.png', './tests/data/clean.bmp') 67 shutil.copy('./tests/data/dirty.png', './tests/data/clean.bmp')
68 with self.assertRaises(ValueError): 68 harmless.HarmlessParser('./tests/data/clean.bmp')
69 images.BMPParser('./tests/data/clean.bmp')
70 os.remove('./tests/data/clean.bmp') 69 os.remove('./tests/data/clean.bmp')
71 70
72 def test_docx(self): 71 def test_docx(self):
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py
index 90f37a8..512efe8 100644
--- a/tests/test_libmat2.py
+++ b/tests/test_libmat2.py
@@ -417,7 +417,7 @@ class TestCleaning(unittest.TestCase):
417 417
418 def test_bmp(self): 418 def test_bmp(self):
419 shutil.copy('./tests/data/dirty.bmp', './tests/data/clean.bmp') 419 shutil.copy('./tests/data/dirty.bmp', './tests/data/clean.bmp')
420 p = images.BMPParser('./tests/data/clean.bmp') 420 p = harmless.HarmlessParser('./tests/data/clean.bmp')
421 421
422 meta = p.get_meta() 422 meta = p.get_meta()
423 self.assertEqual(meta, {}) # bmp has no meta :) 423 self.assertEqual(meta, {}) # bmp has no meta :)
@@ -425,7 +425,7 @@ class TestCleaning(unittest.TestCase):
425 ret = p.remove_all() 425 ret = p.remove_all()
426 self.assertTrue(ret) 426 self.assertTrue(ret)
427 427
428 p = images.BMPParser('./tests/data/clean.cleaned.bmp') 428 p = harmless.HarmlessParser('./tests/data/clean.cleaned.bmp')
429 self.assertEqual(p.get_meta(), {}) 429 self.assertEqual(p.get_meta(), {})
430 430
431 os.remove('./tests/data/clean.bmp') 431 os.remove('./tests/data/clean.bmp')