(bug 31719) Revert r107359 and apply a proper solution for entity expansion in SVGs.
authorTim Starling <tstarling@users.mediawiki.org>
Mon, 2 Jan 2012 03:15:42 +0000 (03:15 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Mon, 2 Jan 2012 03:15:42 +0000 (03:15 +0000)
RELEASE-NOTES-1.19
includes/media/SVGMetadataExtractor.php

index 071c3e4..5855e3e 100644 (file)
@@ -197,7 +197,8 @@ production.
   cssText after DOM insertion.
 * (bug 30711) When adding a new section to a page with section=new, the text is
   now always added to the current version of the page
-* (bug 31719) Recognize &ns_svg; as the svg namespace when extracting width
+* (bug 31719) Fix uploads of SVGs exported by Adobe Illustrator by expanding 
+  XML entities correctly.
 * (bug 30914) Embeddable ResourceLoader modules (user.options, user.tokens)
   should be loaded in <head> for proper dependency resolution
 * (bug 32702) Removed method Skin::makeGlobalVariablesScript() has been readded
index 1da5b94..db9f05f 100644 (file)
@@ -36,7 +36,6 @@ class SVGReader {
        const DEFAULT_WIDTH = 512;
        const DEFAULT_HEIGHT = 512;
        const NS_SVG = 'http://www.w3.org/2000/svg';
-       const ADOBE_SVG_ENTITY = '&ns_svg;';
 
        private $reader = null;
        private $mDebug = false;
@@ -69,6 +68,12 @@ class SVGReader {
                        $this->reader->open( $source, null, LIBXML_NOERROR | LIBXML_NOWARNING );
                }
 
+               // Expand entities, since Adobe Illustrator uses them for xmlns 
+               // attributes (bug 31719). Note that libxml2 has some protection 
+               // against large recursive entity expansions so this is not as 
+               // insecure as it might appear to be.
+               $this->reader->setParserProperty( XMLReader::SUBST_ENTITIES, true );
+
                $this->metadata['width'] = self::DEFAULT_WIDTH;
                $this->metadata['height'] = self::DEFAULT_HEIGHT;
 
@@ -103,10 +108,7 @@ class SVGReader {
                        $keepReading = $this->reader->read();
                }
 
-               # Note, entities not expanded in namespaceURI - bug 31719
-               if ( $this->reader->localName != 'svg' || 
-                       ( $this->reader->namespaceURI != self::NS_SVG &&
-                         $this->reader->namespaceURI != self::ADOBE_SVG_ENTITY ) ) {
+               if ( $this->reader->localName != 'svg' || $this->reader->namespaceURI != self::NS_SVG ) {
                        throw new MWException( "Expected <svg> tag, got ".
                                $this->reader->localName . " in NS " . $this->reader->namespaceURI );
                }