Merge "LogPager: separate getter from query filter"
[lhc/web/wiklou.git] / includes / media / SvgHandler.php
index 4d75d04..98c22a3 100644 (file)
@@ -20,6 +20,8 @@
  * @file
  * @ingroup Media
  */
+
+use MediaWiki\Shell\Shell;
 use Wikimedia\ScopedCallback;
 
 /**
@@ -335,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]
                                );
 
@@ -379,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 ) {
@@ -436,8 +438,10 @@ class SvgHandler extends ImageHandler {
         */
        public function getMetadata( $file, $filename ) {
                $metadata = [ 'version' => self::SVG_METADATA_VERSION ];
+
                try {
-                       $metadata += SVGMetadataExtractor::getMetadata( $filename );
+                       $svgReader = new SVGReader( $filename );
+                       $metadata += $svgReader->getMetadata();
                } catch ( Exception $e ) { // @todo SVG specific exceptions
                        // File not found, broken, etc.
                        $metadata['error'] = [