API: (bug 16105) Image metadata attributes with spaces produce invalid XML. Just...
authorRoan Kattouw <catrope@users.mediawiki.org>
Sat, 25 Oct 2008 15:53:58 +0000 (15:53 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Sat, 25 Oct 2008 15:53:58 +0000 (15:53 +0000)
RELEASE-NOTES
includes/api/ApiFormatXml.php

index 1d850d6..d5c2dcb 100644 (file)
@@ -364,6 +364,7 @@ The following extensions are migrated into MediaWiki 1.14:
 * Added redirect resolution to action=parse
 * (bug 16074) rvprop=content combined with a generator with a high limit causes
   an error
+* (bug 16105) Image metadata attributes containing spaces result in invalid XML
 
 === Languages updated in 1.14 ===
 
index 9514cfc..642ae5c 100644 (file)
@@ -80,6 +80,7 @@ class ApiFormatXml extends ApiFormatBase {
                } else {
                        $indstr = '';
                }
+               $elemName = str_replace(' ', '_', $elemName);
 
                switch (gettype($elemValue)) {
                        case 'array' :
@@ -104,6 +105,14 @@ class ApiFormatXml extends ApiFormatBase {
                                foreach ($elemValue as $subElemId => & $subElemValue) {
                                        if (is_string($subElemValue) && $this->mDoubleQuote)
                                                $subElemValue = $this->doubleQuote($subElemValue);
+                                       
+                                       // Replace spaces with underscores
+                                       $newSubElemId = str_replace(' ', '_', $subElemId);
+                                       if($newSubElemId != $subElemId) {
+                                               $elemValue[$newSubElemId] = $subElemValue;
+                                               unset($elemValue[$subElemId]);
+                                               $subElemId = $newSubElemId;
+                                       }
 
                                        if (gettype($subElemId) === 'integer') {
                                                $indElements[] = $subElemValue;