From 63601400e476c6cf43d985f3e7b9864681695ed4 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 18 Jan 2013 16:46:04 +0100 Subject: Update to MediaWiki 1.20.2 this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024 --- includes/media/SVGMetadataExtractor.php | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'includes/media/SVGMetadataExtractor.php') diff --git a/includes/media/SVGMetadataExtractor.php b/includes/media/SVGMetadataExtractor.php index db9f05fd..851fe428 100644 --- a/includes/media/SVGMetadataExtractor.php +++ b/includes/media/SVGMetadataExtractor.php @@ -1,6 +1,6 @@ + * @author "Derk-Jan Hartman " * @author Brion Vibber * @copyright Copyright © 2010-2010 Brion Vibber, Derk-Jan Hartman * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License */ +/** + * @ingroup Media + */ class SVGMetadataExtractor { static function getMetadata( $filename ) { $svg = new SVGReader( $filename ); @@ -32,6 +35,9 @@ class SVGMetadataExtractor { } } +/** + * @ingroup Media + */ class SVGReader { const DEFAULT_WIDTH = 512; const DEFAULT_HEIGHT = 512; @@ -77,6 +83,12 @@ class SVGReader { $this->metadata['width'] = self::DEFAULT_WIDTH; $this->metadata['height'] = self::DEFAULT_HEIGHT; + // The size in the units specified by the SVG file + // (for the metadata box) + // Per the SVG spec, if unspecified, default to '100%' + $this->metadata['originalWidth'] = '100%'; + $this->metadata['originalHeight'] = '100%'; + // Because we cut off the end of the svg making an invalid one. Complicated // try catch thing to make sure warnings get restored. Seems like there should // be a better way. @@ -84,6 +96,8 @@ class SVGReader { try { $this->read(); } catch( Exception $e ) { + // Note, if this happens, the width/height will be taken to be 0x0. + // Should we consider it the default 512x512 instead? wfRestoreWarnings(); throw $e; } @@ -99,6 +113,7 @@ class SVGReader { /** * Read the SVG + * @return bool */ public function read() { $keepReading = $this->reader->read(); @@ -132,6 +147,11 @@ class SVGReader { $this->readField( $tag, 'description' ); } elseif ( $isSVG && $tag == 'metadata' && $type == XmlReader::ELEMENT ) { $this->readXml( $tag, 'metadata' ); + } elseif ( $isSVG && $tag == 'script' ) { + // We normally do not allow scripted svgs. + // However its possible to configure MW to let them + // in, and such files should be considered animated. + $this->metadata['animated'] = true; } elseif ( $tag !== '#text' ) { $this->debug( "Unhandled top-level XML tag $tag" ); @@ -212,6 +232,11 @@ class SVGReader { break; } elseif ( $this->reader->namespaceURI == self::NS_SVG && $this->reader->nodeType == XmlReader::ELEMENT ) { switch( $this->reader->localName ) { + case 'script': + // Normally we disallow files with + //