*/
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;
+use Psr\Log\NullLogger;
/**
* Implements functions related to MIME types such as detection and mapping to file extension
$this->detectCallback = $params['detectCallback'] ?? null;
$this->guessCallback = $params['guessCallback'] ?? null;
$this->extCallback = $params['extCallback'] ?? null;
- $this->logger = $params['logger'] ?? new \Psr\Log\NullLogger();
+ $this->logger = $params['logger'] ?? new NullLogger();
$this->loadFiles();
}
// Check for ZIP variants (before getimagesize)
$eocdrPos = strpos( $tail, "PK\x05\x06" );
- if ( $eocdrPos !== false ) {
+ if ( $eocdrPos !== false && $eocdrPos <= strlen( $tail ) - 22 ) {
$this->logger->info( __METHOD__ . ": ZIP signature present in $file\n" );
// Check if it really is a ZIP file, make sure the EOCDR is at the end (T40432)
- $commentLength = unpack( "n", substr( $tail, $eocdrPos + 20 ) )[0];
+ $commentLength = unpack( "n", substr( $tail, $eocdrPos + 20 ) )[1];
if ( $eocdrPos + 22 + $commentLength !== strlen( $tail ) ) {
$this->logger->info( __METHOD__ . ": ZIP EOCDR not at end. Not a ZIP file." );
} else {
// Special code for ogg - detect if it's video (theora),
// else label it as sound.
- if ( $mime == 'application/ogg' && file_exists( $path ) ) {
+ if ( $mime == 'application/ogg' && is_string( $path ) && file_exists( $path ) ) {
// Read a chunk of the file
$f = fopen( $path, "rt" );
if ( !$f ) {