r88870 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88869‎ | r88870 | r88871 >
Date:23:57, 25 May 2011
Author:brion
Status:ok (Comments)
Tags:
Comment:
Reverting r82307 (bug 27465) as initial step to recommitting a cleaner fix.
Modified paths:
  • /trunk/phase3/includes/media/SVGMetadataExtractor.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/media/SVGMetadataExtractor.php
@@ -101,7 +101,7 @@
102102 $keepReading = $this->reader->read();
103103 }
104104
105 - if ( !$this->qualifiedNameEquals( $this->reader->name, 'svg', 'svg' ) ) {
 105+ if ( $this->reader->name != 'svg' ) {
106106 throw new MWException( "Expected <svg> tag, got ".
107107 $this->reader->name );
108108 }
@@ -116,13 +116,13 @@
117117
118118 $this->debug( "$tag" );
119119
120 - if ( $this->qualifiedNameEquals( $tag, 'svg', 'svg' ) && $type == XmlReader::END_ELEMENT && $this->reader->depth <= $exitDepth ) {
 120+ if ( $tag == 'svg' && $type == XmlReader::END_ELEMENT && $this->reader->depth <= $exitDepth ) {
121121 break;
122 - } elseif ( $this->qualifiedNameEquals( $tag, 'svg', 'title' ) ) {
 122+ } elseif ( $tag == 'title' ) {
123123 $this->readField( $tag, 'title' );
124 - } elseif ( $this->qualifiedNameEquals( $tag, 'svg', 'desc' ) ) {
 124+ } elseif ( $tag == 'desc' ) {
125125 $this->readField( $tag, 'description' );
126 - } elseif ( $this->qualifiedNameEquals( $tag, 'svg', 'metadata' ) && $type == XmlReader::ELEMENT ) {
 126+ } elseif ( $tag == 'metadata' && $type == XmlReader::ELEMENT ) {
127127 $this->readXml( $tag, 'metadata' );
128128 } elseif ( $tag !== '#text' ) {
129129 $this->debug( "Unhandled top-level XML tag $tag" );
@@ -201,15 +201,10 @@
202202 } elseif ( $this->reader->nodeType == XmlReader::ELEMENT ) {
203203 switch( $this->reader->name ) {
204204 case 'animate':
205 - case 'svg:animate':
206205 case 'set':
207 - case 'svg:set':
208206 case 'animateMotion':
209 - case 'svg:animateMotion':
210207 case 'animateColor':
211 - case 'svg:animateColor':
212208 case 'animateTransform':
213 - case 'svg:animateTransform':
214209 $this->debug( "HOUSTON WE HAVE ANIMATION" );
215210 $this->metadata['animated'] = true;
216211 break;
@@ -318,22 +313,4 @@
319314 return floatval( $length );
320315 }
321316 }
322 -
323 - /**
324 - * XML namespace check
325 - *
326 - * Check if a read node name matches the expected nodeName
327 - * @param $qualifiedName as read by XMLReader
328 - * @param $prefix the namespace prefix that you expect for this element, defaults to svg namespace
329 - * @param $localName the localName part of the element that you want to match
330 - *
331 - * @return boolean
332 - */
333 - private function qualifiedNameEquals( $qualifiedName, $prefix="svg", $localName ) {
334 - if( ($qualifiedName == $localName && $prefix == "svg" ) ||
335 - $qualifiedName == ($prefix . ":" . $localName) ) {
336 - return true;
337 - }
338 - return false;
339 - }
340317 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r88871* (bug 27465) Fix metadata extraction for SVG files using unusual namespace n...brion23:59, 25 May 2011
r896771.17: MFT r88492, r88870, r88871, r89003, r89108, r89114, r89115, r89129, r89...catrope19:14, 7 June 2011
r922841.17wmf1 MFT r88870reedy19:17, 15 July 2011
r92330REL1_18 MFT r88750, r88870, r88871, r89003, r89005, r89114, r89115, r89129, r...reedy22:56, 15 July 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r82307Add support for namespace prefixed elements in svg. ie. <svg:svg>...hartman22:45, 16 February 2011
r88865Test cases for bug 27465: problems with XML namespace handling break SVGMetad...brion23:34, 25 May 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   00:05, 26 May 2011

Combines with r88871 to make the second diff cleaner. Needs merge to 1.17, 1.17-wmf, 1.18 branches and deployment fix for http://en.wikipedia.org/wiki/Wikipedia:Village_pump_%28technical%29#Problems_with_SVG_images

Status & tagging log