Remove HWLDFWordAccumulator, deprecated in 1.28
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderImage.php
index ef11628..27fa5ad 100644 (file)
@@ -20,6 +20,8 @@
  * @file
  */
 
+use MediaWiki\Shell\Shell;
+
 /**
  * Class encapsulating an image used in a ResourceLoaderImageModule.
  *
@@ -73,7 +75,7 @@ class ResourceLoaderImage {
                }
                // Remove 'deprecated' key
                if ( is_array( $this->descriptor ) ) {
-                       unset( $this->descriptor[ 'deprecated' ] );
+                       unset( $this->descriptor['deprecated'] );
                }
 
                // Ensure that all files have common extension.
@@ -295,9 +297,20 @@ class ResourceLoaderImage {
                $dom = new DOMDocument;
                $dom->loadXML( file_get_contents( $this->getPath( $context ) ) );
                $root = $dom->documentElement;
-               $wrapper = $dom->createElement( 'g' );
+               $titleNode = null;
+               $wrapper = $dom->createElementNS( 'http://www.w3.org/2000/svg', 'g' );
+               // Reattach all direct children of the `<svg>` root node to the `<g>` wrapper
                while ( $root->firstChild ) {
-                       $wrapper->appendChild( $root->firstChild );
+                       $node = $root->firstChild;
+                       if ( !$titleNode && $node->nodeType === XML_ELEMENT_NODE && $node->tagName === 'title' ) {
+                               // Remember the first encountered `<title>` node
+                               $titleNode = $node;
+                       }
+                       $wrapper->appendChild( $node );
+               }
+               if ( $titleNode ) {
+                       // Reattach the `<title>` node to the `<svg>` root node rather than the `<g>` wrapper
+                       $root->appendChild( $titleNode );
                }
                $root->appendChild( $wrapper );
                $wrapper->setAttribute( 'fill', $variantConf['color'] );
@@ -362,7 +375,7 @@ class ResourceLoaderImage {
                if ( strpos( $wgSVGConverter, 'rsvg' ) === 0 ) {
                        $command = 'rsvg-convert';
                        if ( $wgSVGConverterPath ) {
-                               $command = wfEscapeShellArg( "$wgSVGConverterPath/" ) . $command;
+                               $command = Shell::escape( "$wgSVGConverterPath/" ) . $command;
                        }
 
                        $process = proc_open(