"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libraries/classes/Mime.php" between
phpMyAdmin-5.0.4-english.zip and phpMyAdmin-5.1.0-english.zip

About: phpMyAdmin is a tool to administrate MySQL databases over the Web (requires at least PHP 7.1).

Mime.php  (phpMyAdmin-5.0.4-english):Mime.php  (phpMyAdmin-5.1.0-english)
<?php <?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/** /**
* MIME detection code. * MIME detection code.
* *
* @package PhpMyAdmin
* @todo Maybe we could try to use fileinfo module if loaded * @todo Maybe we could try to use fileinfo module if loaded
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace PhpMyAdmin; namespace PhpMyAdmin;
use function chr;
use function mb_strlen;
use function mb_substr;
use function substr;
/** /**
* PhpMyAdmin\Mime class; * PhpMyAdmin\Mime class;
*
* @package PhpMyAdmin
*/ */
class Mime class Mime
{ {
/** /**
* Tries to detect MIME type of content. * Tries to detect MIME type of content.
* *
* @param string $test First few bytes of content to use for detection * @param string $test First few bytes of content to use for detection
* *
* @return string * @return string
*/ */
public static function detect(&$test) public static function detect(&$test)
{ {
$len = mb_strlen($test); $len = mb_strlen($test);
if ($len >= 2 && $test[0] == chr(0xff) && $test[1] == chr(0xd8)) { if ($len >= 2 && $test[0] == chr(0xff) && $test[1] == chr(0xd8)) {
return 'image/jpeg'; return 'image/jpeg';
} }
if ($len >= 3 && substr($test, 0, 3) == 'GIF') { if ($len >= 3 && substr($test, 0, 3) === 'GIF') {
return 'image/gif'; return 'image/gif';
} }
if ($len >= 4 && mb_substr($test, 0, 4) == "\x89PNG") { if ($len >= 4 && mb_substr($test, 0, 4) == "\x89PNG") {
return 'image/png'; return 'image/png';
} }
return 'application/octet-stream'; return 'application/octet-stream';
} }
} }
 End of changes. 7 change blocks. 
5 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)