From 9d10834864d87beae6062ccdc88085a9348ef641 Mon Sep 17 00:00:00 2001 From: Kevin Israel Date: Mon, 8 Apr 2013 20:25:47 -0400 Subject: [PATCH] ApiFormatXml: remove broken xmldoublequote param r55641 was a refactoring of ApiFormatXml::recXmlPrint() that added a $doublequote parameter, yet the parameter was not actually passed along in recursive calls, rendering the formatter's xmldoublequote parameter useless. XPath support was the sole reason this parameter was added. It was argued that because in the XPath 1.0 grammar, a Literal is: '"' [^"]* '"' | "'" [^']* "'" it is not possible to match attribute values that contain both an apostrophe and a double quote. However, conforming XPath implementations include a concat() function that can be used to work around this limitation. Furthermore, XPath 2.0 allows escaping a double-quoted " as "" (and a single-quoted ' as ''). Because there was no Bugzilla report (other than mine) filed in the last 3-1/2 years, and working around the XPath flaw is possible, I think it's safe to remove the parameter. The worst that could happen is that a not-very-robust API client chokes on the "Unrecognized parameter" warning. Bug: 46626 Change-Id: I9a4d8c13b78ffd2634d03c8c8b4bbeff69f4bc08 --- RELEASE-NOTES-1.22 | 3 +++ includes/api/ApiFormatXml.php | 17 ++--------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index 95da63b9f9..116c58e753 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -17,6 +17,9 @@ production. === Bug fixes in 1.22 === === API changes in 1.22 === +* (bug 46626) xmldoublequote parameter was removed. Because of a bug, the + parameter has had no effect since MediaWiki 1.16, and so its removal is + unlikely to impact existing clients. === Languages updated in 1.22=== diff --git a/includes/api/ApiFormatXml.php b/includes/api/ApiFormatXml.php index 183d48c44f..f9b85efabb 100644 --- a/includes/api/ApiFormatXml.php +++ b/includes/api/ApiFormatXml.php @@ -32,7 +32,6 @@ class ApiFormatXml extends ApiFormatBase { private $mRootElemName = 'api'; public static $namespace = 'http://www.mediawiki.org/xml/api/'; - private $mDoubleQuote = false; private $mIncludeNamespace = false; private $mXslt = null; @@ -50,7 +49,6 @@ class ApiFormatXml extends ApiFormatBase { public function execute() { $params = $this->extractRequestParams(); - $this->mDoubleQuote = $params['xmldoublequote']; $this->mIncludeNamespace = $params['includexmlnamespace']; $this->mXslt = $params['xslt']; @@ -71,8 +69,7 @@ class ApiFormatXml extends ApiFormatBase { $this->printText( self::recXmlPrint( $this->mRootElemName, $data, - $this->getIsHtml() ? - 2 : null, - $this->mDoubleQuote + $this->getIsHtml() ? - 2 : null ) ); } @@ -117,11 +114,10 @@ class ApiFormatXml extends ApiFormatBase { * @param $elemName * @param $elemValue * @param $indent - * @param $doublequote bool * * @return string */ - public static function recXmlPrint( $elemName, $elemValue, $indent, $doublequote = false ) { + public static function recXmlPrint( $elemName, $elemValue, $indent ) { $retval = ''; if ( !is_null( $indent ) ) { $indent += 2; @@ -134,9 +130,6 @@ class ApiFormatXml extends ApiFormatBase { if ( is_array( $elemValue ) ) { if ( isset( $elemValue['*'] ) ) { $subElemContent = $elemValue['*']; - if ( $doublequote ) { - $subElemContent = Sanitizer::encodeAttribute( $subElemContent ); - } unset( $elemValue['*'] ); // Add xml:space="preserve" to the @@ -157,10 +150,6 @@ class ApiFormatXml extends ApiFormatBase { $indElements = array(); $subElements = array(); foreach ( $elemValue as $subElemId => & $subElemValue ) { - if ( is_string( $subElemValue ) && $doublequote ) { - $subElemValue = Sanitizer::encodeAttribute( $subElemValue ); - } - if ( is_int( $subElemId ) ) { $indElements[] = $subElemValue; unset( $elemValue[$subElemId] ); @@ -226,7 +215,6 @@ class ApiFormatXml extends ApiFormatBase { public function getAllowedParams() { return array( - 'xmldoublequote' => false, 'xslt' => null, 'includexmlnamespace' => false, ); @@ -234,7 +222,6 @@ class ApiFormatXml extends ApiFormatBase { public function getParamDescription() { return array( - 'xmldoublequote' => 'If specified, double quotes all attributes and content', 'xslt' => 'If specified, adds as stylesheet. This should be a wiki page ' . 'in the MediaWiki namespace whose page name ends with ".xsl"', 'includexmlnamespace' => 'If specified, adds an XML namespace' -- 2.20.1