* @ingroup Media
*/
+use MediaWiki\Shell\Shell;
+
/**
* Support for detecting/validating DjVu image files and getting
* some basic file metadata (resolution etc)
* @ingroup Media
*/
class DjVuImage {
+
/**
- * @const DJVUTXT_MEMORY_LIMIT Memory limit for the DjVu description software
+ * Memory limit for the DjVu description software
*/
const DJVUTXT_MEMORY_LIMIT = 300000;
/**
* Return data in the style of getimagesize()
- * @return array|bool Array or false on failure
+ * @return array|false Array or false on failure
*/
public function getImageSize() {
$data = $this->getInfo();
$this->dumpForm( $file, $chunkLength, $indent + 1 );
} else {
fseek( $file, $chunkLength, SEEK_CUR );
- if ( $chunkLength & 1 == 1 ) {
+ if ( $chunkLength & 1 ) {
// Padding byte between chunks
fseek( $file, 1, SEEK_CUR );
}
private function skipChunk( $file, $chunkLength ) {
fseek( $file, $chunkLength, SEEK_CUR );
- if ( $chunkLength & 0x01 == 1 && !feof( $file ) ) {
+ if ( ( $chunkLength & 1 ) && !feof( $file ) ) {
// padding byte
fseek( $file, 1, SEEK_CUR );
}
if ( isset( $wgDjvuDump ) ) {
# djvudump is faster as of version 3.5
# https://sourceforge.net/p/djvu/bugs/71/
- $cmd = wfEscapeShellArg( $wgDjvuDump ) . ' ' . wfEscapeShellArg( $this->mFilename );
+ $cmd = Shell::escape( $wgDjvuDump ) . ' ' . Shell::escape( $this->mFilename );
$dump = wfShellExec( $cmd );
$xml = $this->convertDumpToXML( $dump );
} elseif ( isset( $wgDjvuToXML ) ) {
- $cmd = wfEscapeShellArg( $wgDjvuToXML ) . ' --without-anno --without-text ' .
- wfEscapeShellArg( $this->mFilename );
+ $cmd = Shell::escape( $wgDjvuToXML ) . ' --without-anno --without-text ' .
+ Shell::escape( $this->mFilename );
$xml = wfShellExec( $cmd );
} else {
$xml = null;
}
# Text layer
if ( isset( $wgDjvuTxt ) ) {
- $cmd = wfEscapeShellArg( $wgDjvuTxt ) . ' --detail=page ' . wfEscapeShellArg( $this->mFilename );
+ $cmd = Shell::escape( $wgDjvuTxt ) . ' --detail=page ' . Shell::escape( $this->mFilename );
wfDebug( __METHOD__ . ": $cmd\n" );
$retval = '';
$txt = wfShellExec( $cmd, $retval, [], [ 'memory' => self::DJVUTXT_MEMORY_LIMIT ] );