From cf7552eff5adc1d669b9dc25ef7e1d519db7c3df Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sat, 23 Nov 2024 11:07:11 -0300 Subject: [PATCH] ImageExtractor: Improve BMP detection to prevent situations with all 00 bytes --- biostools/extractors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/biostools/extractors.py b/biostools/extractors.py index 8df4141..809690f 100644 --- a/biostools/extractors.py +++ b/biostools/extractors.py @@ -891,7 +891,7 @@ class ImageExtractor(Extractor): # Header pattern for common format images. self._pil_pattern = re.compile( b'''\\x0A[\\x00-\\x05][\\x00-\\x01][\\x01\\x02\\x04\\x08]|''' # PCX - b'''BM[\\x00-\\xFF]{3}\\x00[\\x00-\\xFF]{7}\\x00|''' # BMP (limited to 16 MB size and start offset) + b'''BM(?!\\x00{3})[\\x00-\\xFF]{3}\\x00[\\x00-\\xFF]{4}(?!\\x00{3})[\\x00-\\xFF]{3}\\x00|''' # BMP (limited to 16 MB size and start offset) b'''\\xFF\\xD8\\xFF|''' # JPEG b'''GIF8[79]a|''' # GIF b'''\\x89PNG''' # PNG