From f8dc72921fb91e45ee9190f25df16b9b0224c191 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Sat, 25 Oct 2008 15:53:58 +0000 Subject: [PATCH] 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. --- RELEASE-NOTES | 1 + includes/api/ApiFormatXml.php | 9 +++++++++ 2 files changed, 10 insertions(+) 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; -- 2.20.1