From 583c33c9f7d7ee33ef6a748ec4e4370c6a3b7607 Mon Sep 17 00:00:00 2001 From: Ville-Pekka Vainio Date: Wed, 20 Aug 2025 12:12:30 +0300 Subject: [PATCH] FLI/FLC _accept: Check for 8-bit colour depth Standard FLI/FLC files always have 8-bit color depth. This change helps avoid erroneously detecting some TIFFs as FLI/FLC files. Update test files Tests/images/timeout-9139147ce93e20eb14088fe238e541443ffd64b3.fli and Tests/images/timeout-bff0a9dc7243a8e6ede2408d2ffa6a9964698b87.fli to claim to have 8-bit colour depth so that the tests related to them will still work. --- ...9139147ce93e20eb14088fe238e541443ffd64b3.fli | Bin 200 -> 200 bytes ...bff0a9dc7243a8e6ede2408d2ffa6a9964698b87.fli | Bin 159 -> 159 bytes src/PIL/FliImagePlugin.py | 1 + 3 files changed, 1 insertion(+) diff --git a/Tests/images/timeout-9139147ce93e20eb14088fe238e541443ffd64b3.fli b/Tests/images/timeout-9139147ce93e20eb14088fe238e541443ffd64b3.fli index ce4607d2dd083a923db2d6326e5b6cb34edd0702..a7a3bd546e1dbd0c62a25aa873d3c788373b38ba 100644 GIT binary patch delta 21 dcmX@Xc!H7l{y&Drg6p{$7zKQVIVSS%1^`oY2D|_O delta 21 dcmX@Xc!H7l{y&Drg6p{$7zKQV|4-!I4FFe92eSYG diff --git a/Tests/images/timeout-bff0a9dc7243a8e6ede2408d2ffa6a9964698b87.fli b/Tests/images/timeout-bff0a9dc7243a8e6ede2408d2ffa6a9964698b87.fli index 77a94b87a3ade935e707f3d89c9fbff801a1e976..4bc18b06a1cac1e05e5b4d7c088323e23ca80de1 100644 GIT binary patch delta 21 dcmbQwIG>UC{y&Drg6p{$7zG#vI41H=0su<|1@Qm? delta 21 dcmbQwIG>UC{y&Drg6p{$7zG#v{!iqc1OQIq2Iv3) diff --git a/src/PIL/FliImagePlugin.py b/src/PIL/FliImagePlugin.py index 7c5bfeefa..727a1316d 100644 --- a/src/PIL/FliImagePlugin.py +++ b/src/PIL/FliImagePlugin.py @@ -32,6 +32,7 @@ def _accept(prefix: bytes) -> bool: return ( len(prefix) >= 6 and i16(prefix, 4) in [0xAF11, 0xAF12] + and i16(prefix, 12) == 8 # 8-bit colour and i16(prefix, 14) in [0, 3] # flags )