From: Brad Jorsch Date: Thu, 30 Apr 2015 13:00:04 +0000 (-0400) Subject: API: Also mangle indexed tag names in format=xml X-Git-Tag: 1.31.0-rc.0~11541^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=commitdiff_plain;h=4bbd86a859392c390755e8b2ce55f31fdc1f97ae;p=lhc%2Fweb%2Fwiklou.git API: Also mangle indexed tag names in format=xml I had thought no one would be silly enough to set invalid tag names for ApiResult::setIndexedTagName(), since it's specifically *for* XML tag names. Apparently I was wrong. Bug: T97599 Change-Id: I62ad832b1d8c23a275e5c67160f0b1febe5f3454 --- diff --git a/includes/api/ApiFormatXml.php b/includes/api/ApiFormatXml.php index dbd56453c0..fa0bac3406 100644 --- a/includes/api/ApiFormatXml.php +++ b/includes/api/ApiFormatXml.php @@ -130,7 +130,7 @@ class ApiFormatXml extends ApiFormatBase { ? $value[ApiResult::META_PRESERVE_KEYS] : array(); $indexedTagName = isset( $value[ApiResult::META_INDEXED_TAG_NAME] ) - ? $value[ApiResult::META_INDEXED_TAG_NAME] + ? self::mangleName( $value[ApiResult::META_INDEXED_TAG_NAME], $preserveKeys ) : '_v'; $bcBools = isset( $value[ApiResult::META_BC_BOOLS] ) ? $value[ApiResult::META_BC_BOOLS] diff --git a/tests/phpunit/includes/api/format/ApiFormatXmlTest.php b/tests/phpunit/includes/api/format/ApiFormatXmlTest.php index 0c31b95770..7babaedb9b 100644 --- a/tests/phpunit/includes/api/format/ApiFormatXmlTest.php +++ b/tests/phpunit/includes/api/format/ApiFormatXmlTest.php @@ -94,6 +94,8 @@ class ApiFormatXmlTest extends ApiFormatTestBase { array( array( "foo\xe3\x80\x80bar" => 1 ), '' ), array( array( 'foo:bar' => 1, ApiResult::META_PRESERVE_KEYS => array( 'foo:bar' ) ), '' ), + array( array( 'a', 'b', ApiResult::META_INDEXED_TAG_NAME => 'foo bar' ), + '<_foo.20.bar>a<_foo.20.bar>b' ), // includenamespace param array( array( 'x' => 'foo' ), '',