-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed as not planned
Closed as not planned
Copy link
Description
Description
The following code:
$magicFile = __DIR__ . DIRECTORY_SEPARATOR . 'magic私はガラスを食べられます';
$options = array(
FILEINFO_NONE,
FILEINFO_MIME,
);
$buffers = array(
"Regular string here",
"\177ELF",
"\000\000\0001\000\000\0000\000\000\0000\000\000\0002\000\000\0000\000\000\0000\000\000\0003",
"\x55\x7A\x6E\x61",
"id=ImageMagick\x0a\x0c\x0a:\x1a",
"RIFFüîò^BAVI LISTv",
);
echo "*** Testing finfo_buffer() : basic functionality ***\n";
foreach( $options as $option ) {
$finfo = finfo_open( $option, $magicFile );
foreach( $buffers as $string ) {
var_dump( finfo_buffer( $finfo, $string, $option ) );
}
finfo_close( $finfo );
}
<?phpResulted in this output:
*** Testing finfo_buffer() : basic functionality ***
Warning: finfo_open(/test_php/source/php/ext/fileinfo/tests/magic私はガラスを食べられます): Failed to open stream: No such file or directory in /test_php/source/php/ext/fileinfo/tests/finfo_buffer_basic-mb.php on line 21
Warning: finfo_open(/test_php/source/php/ext/fileinfo/tests/magic私はガラスを食べられます): Failed to open stream: No such file or directory in /test_php/source/php/ext/fileinfo/tests/finfo_buffer_basic-mb.php on line 21
Warning: finfo_open(): Failed to load magic database at "/test_php/source/php/ext/fileinfo/tests/magic私はガラスを食べられます" in /test_php/source/php/ext/fileinfo/tests/finfo_buffer_basic-mb.php on line 21
Fatal error: Uncaught TypeError: finfo_buffer(): Argument #1 ($finfo) must be of type finfo, false given in /test_php/source/php/ext/fileinfo/tests/finfo_buffer_basic-mb.php:23
Stack trace:
#0 /test_php/source/php/ext/fileinfo/tests/finfo_buffer_basic-mb.php(23): finfo_buffer(false, 'Regular string ...', 0)
#1 {main}
thrown in /test_php/source/php/ext/fileinfo/tests/finfo_buffer_basic-mb.php on line 23
But I expected this output instead:
*** Testing finfo_buffer() : basic functionality ***
string(36) "ASCII text, with no line terminators"
string(3) "ELF"
string(22) "old ACE/gr binary file"
string(12) "xo65 object,"
string(15) "MIFF image data"
string(25) "RIFF (little-endian) data"
string(28) "text/plain; charset=us-ascii"
string(26) "text/plain; charset=ebcdic"
string(40) "application/octet-stream; charset=binary"
string(28) "text/plain; charset=us-ascii"
string(28) "image/x-miff; charset=binary"
string(25) "text/plain; charset=utf-8"
PHP Version
PHP 8.4.17RC1 (cli) (built: Jan 25 2026 21:1817) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.17RC1, Copyright (c) Zend Technologies
Operating System
Debian GNU/Linux 12 (bookworm) x86_64 (container run with podman)