X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fmedia%2FSvgHandler.php;h=e12f596c1110e628807d38ddae3c6f70bd097aee;hb=6207fa9be1118b878505edceecc1f9748c8d74f8;hp=b7745df9bcc9db374c9ce70cbba00fdde7a3ddab;hpb=91a693919e2e704114f2e69e3282577e4c47bb15;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/media/SvgHandler.php b/includes/media/SvgHandler.php index b7745df9bc..e12f596c11 100644 --- a/includes/media/SvgHandler.php +++ b/includes/media/SvgHandler.php @@ -20,6 +20,8 @@ * @file * @ingroup Media */ + +use MediaWiki\Shell\Shell; use Wikimedia\ScopedCallback; /** @@ -199,20 +201,16 @@ class SvgHandler extends ImageHandler { $params['physicalWidth'] = $wgSVGMaxSize; $params['physicalHeight'] = File::scaleHeight( $srcWidth, $srcHeight, $wgSVGMaxSize ); } - } else { - if ( $params['physicalHeight'] > $wgSVGMaxSize ) { - $srcWidth = $image->getWidth( $params['page'] ); - $srcHeight = $image->getHeight( $params['page'] ); - $params['physicalWidth'] = File::scaleHeight( $srcHeight, $srcWidth, $wgSVGMaxSize ); - $params['physicalHeight'] = $wgSVGMaxSize; - } + } elseif ( $params['physicalHeight'] > $wgSVGMaxSize ) { + $srcWidth = $image->getWidth( $params['page'] ); + $srcHeight = $image->getHeight( $params['page'] ); + $params['physicalWidth'] = File::scaleHeight( $srcHeight, $srcWidth, $wgSVGMaxSize ); + $params['physicalHeight'] = $wgSVGMaxSize; } // To prevent the proliferation of thumbnails in languages not present in SVGs, unless // explicitly forced by user. - if ( isset( $params['targetlang'] ) ) { - if ( !$image->getMatchedLanguage( $params['targetlang'] ) ) { - unset( $params['targetlang'] ); - } + if ( isset( $params['targetlang'] ) && !$image->getMatchedLanguage( $params['targetlang'] ) ) { + unset( $params['targetlang'] ); } return $params; @@ -339,11 +337,11 @@ class SvgHandler extends ImageHandler { // External command $cmd = str_replace( [ '$path/', '$width', '$height', '$input', '$output' ], - [ $wgSVGConverterPath ? wfEscapeShellArg( "$wgSVGConverterPath/" ) : "", + [ $wgSVGConverterPath ? Shell::escape( "$wgSVGConverterPath/" ) : "", intval( $width ), intval( $height ), - wfEscapeShellArg( $srcPath ), - wfEscapeShellArg( $dstPath ) ], + Shell::escape( $srcPath ), + Shell::escape( $dstPath ) ], $wgSVGConverters[$wgSVGConverter] ); @@ -383,7 +381,7 @@ class SvgHandler extends ImageHandler { * @param File|FSFile $file * @param string $path Unused * @param bool|array $metadata - * @return array + * @return array|false */ function getImageSize( $file, $path, $metadata = false ) { if ( $metadata === false && $file instanceof File ) {