r107793 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107792‎ | r107793 | r107794 >
Date:03:15, 2 January 2012
Author:tstarling
Status:ok (Comments)
Tags:
Comment:
(bug 31719) Revert r107359 and apply a proper solution for entity expansion in SVGs.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/includes/media/SVGMetadataExtractor.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -197,7 +197,8 @@
198198 cssText after DOM insertion.
199199 * (bug 30711) When adding a new section to a page with section=new, the text is
200200 now always added to the current version of the page
201 -* (bug 31719) Recognize &ns_svg; as the svg namespace when extracting width
 201+* (bug 31719) Fix uploads of SVGs exported by Adobe Illustrator by expanding
 202+ XML entities correctly.
202203 * (bug 30914) Embeddable ResourceLoader modules (user.options, user.tokens)
203204 should be loaded in <head> for proper dependency resolution
204205 * (bug 32702) Removed method Skin::makeGlobalVariablesScript() has been readded
Index: trunk/phase3/includes/media/SVGMetadataExtractor.php
@@ -36,7 +36,6 @@
3737 const DEFAULT_WIDTH = 512;
3838 const DEFAULT_HEIGHT = 512;
3939 const NS_SVG = 'http://www.w3.org/2000/svg';
40 - const ADOBE_SVG_ENTITY = '&ns_svg;';
4140
4241 private $reader = null;
4342 private $mDebug = false;
@@ -69,6 +68,12 @@
7069 $this->reader->open( $source, null, LIBXML_NOERROR | LIBXML_NOWARNING );
7170 }
7271
 72+ // Expand entities, since Adobe Illustrator uses them for xmlns
 73+ // attributes (bug 31719). Note that libxml2 has some protection
 74+ // against large recursive entity expansions so this is not as
 75+ // insecure as it might appear to be.
 76+ $this->reader->setParserProperty( XMLReader::SUBST_ENTITIES, true );
 77+
7378 $this->metadata['width'] = self::DEFAULT_WIDTH;
7479 $this->metadata['height'] = self::DEFAULT_HEIGHT;
7580
@@ -103,10 +108,7 @@
104109 $keepReading = $this->reader->read();
105110 }
106111
107 - # Note, entities not expanded in namespaceURI - bug 31719
108 - if ( $this->reader->localName != 'svg' ||
109 - ( $this->reader->namespaceURI != self::NS_SVG &&
110 - $this->reader->namespaceURI != self::ADOBE_SVG_ENTITY ) ) {
 112+ if ( $this->reader->localName != 'svg' || $this->reader->namespaceURI != self::NS_SVG ) {
111113 throw new MWException( "Expected <svg> tag, got ".
112114 $this->reader->localName . " in NS " . $this->reader->namespaceURI );
113115 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r107940PHPUnit test case for bug 31719 (followup r107793)brion21:12, 3 January 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r107359(bug 31719) Apply Derk-Jan Hartman's patch to make '&ns_svg;' considered a na...bawolff02:57, 27 December 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   21:08, 3 January 2012

Needs a phpunit test case; will add one.

#Comment by Brion VIBBER (talk | contribs)   21:13, 3 January 2012

Added in r107940. Confirmed that taking out the subst check has the metadata checks on this file fail.

Status & tagging log