From: Roan Kattouw Date: Sat, 25 Oct 2008 15:53:58 +0000 (+0000) Subject: API: (bug 16105) Image metadata attributes with spaces produce invalid XML. Just... X-Git-Tag: 1.31.0-rc.0~44602 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/categories/modifier.php?a=commitdiff_plain;h=f8dc72921fb91e45ee9190f25df16b9b0224c191;p=lhc%2Fweb%2Fwiklou.git API: (bug 16105) Image metadata attributes with spaces produce invalid XML. Just replace spaces with underscores in the XML formatter and be done with it. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 1d850d61ff..d5c2dcb9ce 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/api/ApiFormatXml.php b/includes/api/ApiFormatXml.php index 9514cfc3fc..642ae5cb11 100644 --- a/includes/api/ApiFormatXml.php +++ b/includes/api/ApiFormatXml.php @@ -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;