Skip comments and stuff before the <svg> element.
authorDerk-Jan Hartman <hartman@users.mediawiki.org>
Thu, 4 Nov 2010 13:42:42 +0000 (13:42 +0000)
committerDerk-Jan Hartman <hartman@users.mediawiki.org>
Thu, 4 Nov 2010 13:42:42 +0000 (13:42 +0000)
includes/media/SVGMetadataExtractor.php

index 66dc125..a46d838 100644 (file)
@@ -67,18 +67,21 @@ class SVGReader {
         * Read the SVG
         */
        public function read() {
-               $this->reader->read();
+               $keepReading = $this->reader->read();
+
+               /* Skip until first element */
+               while( $keepReading && $this->reader->nodeType != XmlReader::ELEMENT ) {
+                       $keepReading = $this->reader->read();
+               }
 
                if ( $this->reader->name != 'svg' ) {
                        throw new MWException( "Expected <svg> tag, got ".
                                $this->reader->name );
                }
                $this->debug( "<svg> tag is correct." );
-
-               $this->debug( "Starting primary dump processing loop." );
                $this->handleSVGAttribs();
-               $exitDepth =  $this->reader->depth;
 
+               $exitDepth =  $this->reader->depth;
                $keepReading = $this->reader->read();
                $skip = false;
                while ( $keepReading ) {