X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fmedia%2FBitmapHandler.php;h=2d1c3b2b51de9e7cc78ff47a6832310d8d19e04a;hb=08e27d6d40ed2f6eea8abc509254e11c92212a8d;hp=b8b706d48849b0a371ae48113cb49b17ee799ad6;hpb=867ec0704035708b91a3003275732a25e0f55644;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/media/BitmapHandler.php b/includes/media/BitmapHandler.php index b8b706d488..2d1c3b2b51 100644 --- a/includes/media/BitmapHandler.php +++ b/includes/media/BitmapHandler.php @@ -21,6 +21,8 @@ * @ingroup Media */ +use MediaWiki\Shell\Shell; + /** * Generic handler for bitmap images * @@ -228,7 +230,7 @@ class BitmapHandler extends TransformationalImageHandler { $rotation = isset( $params['disableRotation'] ) ? 0 : $this->getRotation( $image ); list( $width, $height ) = $this->extractPreRotationDimensions( $params, $rotation ); - $cmd = wfEscapeShellArg( ...array_merge( + $cmd = Shell::escape( ...array_merge( [ $wgImageMagickConvertCommand ], $quality, // Specify white background color, will be used for transparent images @@ -338,10 +340,8 @@ class BitmapHandler extends TransformationalImageHandler { } $im->setImageDepth( 8 ); - if ( $rotation ) { - if ( !$im->rotateImage( new ImagickPixel( 'white' ), 360 - $rotation ) ) { - return $this->getMediaTransformError( $params, "Error rotating $rotation degrees" ); - } + if ( $rotation && !$im->rotateImage( new ImagickPixel( 'white' ), 360 - $rotation ) ) { + return $this->getMediaTransformError( $params, "Error rotating $rotation degrees" ); } if ( $this->isAnimatedImage( $image ) ) { @@ -375,12 +375,12 @@ class BitmapHandler extends TransformationalImageHandler { global $wgCustomConvertCommand; # Variables: %s %d %w %h - $src = wfEscapeShellArg( $params['srcPath'] ); - $dst = wfEscapeShellArg( $params['dstPath'] ); + $src = Shell::escape( $params['srcPath'] ); + $dst = Shell::escape( $params['dstPath'] ); $cmd = $wgCustomConvertCommand; $cmd = str_replace( '%s', $src, str_replace( '%d', $dst, $cmd ) ); # Filenames - $cmd = str_replace( '%h', wfEscapeShellArg( $params['physicalHeight'] ), - str_replace( '%w', wfEscapeShellArg( $params['physicalWidth'] ), $cmd ) ); # Size + $cmd = str_replace( '%h', Shell::escape( $params['physicalHeight'] ), + str_replace( '%w', Shell::escape( $params['physicalWidth'] ), $cmd ) ); # Size wfDebug( __METHOD__ . ": Running custom convert command $cmd\n" ); $retval = 0; $err = wfShellExecWithStderr( $cmd, $retval ); @@ -571,10 +571,10 @@ class BitmapHandler extends TransformationalImageHandler { $scaler = $this->getScalerType( null, false ); switch ( $scaler ) { case 'im': - $cmd = wfEscapeShellArg( $wgImageMagickConvertCommand ) . " " . - wfEscapeShellArg( $this->escapeMagickInput( $params['srcPath'], $scene ) ) . - " -rotate " . wfEscapeShellArg( "-$rotation" ) . " " . - wfEscapeShellArg( $this->escapeMagickOutput( $params['dstPath'] ) ); + $cmd = Shell::escape( $wgImageMagickConvertCommand ) . " " . + Shell::escape( $this->escapeMagickInput( $params['srcPath'], $scene ) ) . + " -rotate " . Shell::escape( "-$rotation" ) . " " . + Shell::escape( $this->escapeMagickOutput( $params['dstPath'] ) ); wfDebug( __METHOD__ . ": running ImageMagick: $cmd\n" ); $retval = 0; $err = wfShellExecWithStderr( $cmd, $retval );