mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fix GH-20201: AVIF images misdetected as HEIF after introducing HEIF support in getimagesize()
Closes GH-20234.
This commit is contained in:
committed by
Niels Dossche
parent
ebf9d84055
commit
0b974dd663
2
NEWS
2
NEWS
@@ -19,6 +19,8 @@ PHP NEWS
|
||||
- Standard:
|
||||
. Fixed bug GH-20257 (mail() heap overflow with an empty message in lf mode).
|
||||
(David Carlier)
|
||||
. Fixed bug GH-20201 (AVIF images misdetected as HEIF after introducing HEIF
|
||||
support in getimagesize()). (nielsdos)
|
||||
|
||||
- Streams:
|
||||
. Fixed bug GH-19798: XP_SOCKET XP_SSL (Socket stream modules): Incorrect
|
||||
|
||||
@@ -1435,15 +1435,16 @@ PHPAPI int php_getimagetype(php_stream *stream, const char *input, char *filetyp
|
||||
return IMAGE_FILETYPE_JP2;
|
||||
}
|
||||
|
||||
if (!php_stream_rewind(stream) && php_is_image_avif(stream)) {
|
||||
return IMAGE_FILETYPE_AVIF;
|
||||
}
|
||||
|
||||
/* See GH-20201: this needs to be after avif checks to avoid identifying avif as heif. */
|
||||
if (twelve_bytes_read && !memcmp(filetype + 4, php_sig_ftyp, 4) &&
|
||||
(!memcmp(filetype + 8, php_sig_mif1, 4) || !memcmp(filetype + 8, php_sig_heic, 4) || !memcmp(filetype + 8, php_sig_heix, 4))) {
|
||||
return IMAGE_FILETYPE_HEIF;
|
||||
}
|
||||
|
||||
if (!php_stream_rewind(stream) && php_is_image_avif(stream)) {
|
||||
return IMAGE_FILETYPE_AVIF;
|
||||
}
|
||||
|
||||
/* AFTER ALL ABOVE FAILED */
|
||||
if (php_get_wbmp(stream, NULL, 1)) {
|
||||
return IMAGE_FILETYPE_WBMP;
|
||||
|
||||
BIN
ext/standard/tests/image/gh20201.avif
Normal file
BIN
ext/standard/tests/image/gh20201.avif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 325 B |
27
ext/standard/tests/image/gh20201.phpt
Normal file
27
ext/standard/tests/image/gh20201.phpt
Normal file
@@ -0,0 +1,27 @@
|
||||
--TEST--
|
||||
GH-20201 (AVIF images misdetected as HEIF after introducing HEIF support in getimagesize())
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(getimagesize(__DIR__ . '/gh20201.avif'));
|
||||
?>
|
||||
--EXPECT--
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(8)
|
||||
[1]=>
|
||||
int(8)
|
||||
[2]=>
|
||||
int(19)
|
||||
[3]=>
|
||||
string(20) "width="8" height="8""
|
||||
["bits"]=>
|
||||
int(8)
|
||||
["channels"]=>
|
||||
int(3)
|
||||
["mime"]=>
|
||||
string(10) "image/avif"
|
||||
["width_unit"]=>
|
||||
string(2) "px"
|
||||
["height_unit"]=>
|
||||
string(2) "px"
|
||||
}
|
||||
Reference in New Issue
Block a user