X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fmedia%2FDjVuImage.php;h=92fad528febf22faca6dea69d6c060db3d15f4a5;hb=6207fa9be1118b878505edceecc1f9748c8d74f8;hp=d059cd82898ac9cba1a5ed2e596e4f1df8440d46;hpb=5a2e5db4fcbdd18128c62200ffabbeb652850203;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/media/DjVuImage.php b/includes/media/DjVuImage.php index d059cd8289..92fad528fe 100644 --- a/includes/media/DjVuImage.php +++ b/includes/media/DjVuImage.php @@ -24,6 +24,8 @@ * @ingroup Media */ +use MediaWiki\Shell\Shell; + /** * Support for detecting/validating DjVu image files and getting * some basic file metadata (resolution etc) @@ -34,8 +36,9 @@ * @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; @@ -58,7 +61,7 @@ class DjVuImage { /** * 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(); @@ -108,7 +111,7 @@ class DjVuImage { $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 ); } @@ -166,7 +169,7 @@ class DjVuImage { 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 ); } @@ -253,19 +256,19 @@ class DjVuImage { 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 ] );