mirror of
https://github.com/Intervention/image.git
synced 2025-08-20 04:31:24 +02:00
GIF detection: Only check the first 6 bytes of the input (#1441)
* Only check the first 6 bytes of the input to reduce memory usage and speed up the detection * Update src/Drivers/AbstractDecoder.php Co-authored-by: Oliver Vogel <oliver@olivervogel.com> --------- Co-authored-by: Oliver Vogel <oliver@olivervogel.com>
This commit is contained in:
@@ -22,9 +22,11 @@ abstract class AbstractDecoder implements DecoderInterface
|
||||
*/
|
||||
protected function isGifFormat(string $input): bool
|
||||
{
|
||||
$head = substr($input, 0, 6);
|
||||
|
||||
return 1 === preg_match(
|
||||
"/^47494638(37|39)61/",
|
||||
strtoupper(substr(bin2hex($input), 0, 32))
|
||||
strtoupper(bin2hex($head))
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user