PleaseStand has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/58261


Change subject: ApiFormatXml: remove broken xmldoublequote param
......................................................................

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.

I also changed the function's visibility from public to private, as
no other file (neither in core nor extensions) seems to be using the
function.

Bug: 46626
Change-Id: I9a4d8c13b78ffd2634d03c8c8b4bbeff69f4bc08
---
M RELEASE-NOTES-1.22
M includes/api/ApiFormatXml.php
2 files changed, 5 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/61/58261/1

diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22
index 5c0098d..3fa55ba 100644
--- a/RELEASE-NOTES-1.22
+++ b/RELEASE-NOTES-1.22
@@ -16,6 +16,9 @@
 === 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 183d48c..ca003ed 100644
--- a/includes/api/ApiFormatXml.php
+++ b/includes/api/ApiFormatXml.php
@@ -32,7 +32,6 @@
 
        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 @@
 
        public function execute() {
                $params = $this->extractRequestParams();
-               $this->mDoubleQuote = $params['xmldoublequote'];
                $this->mIncludeNamespace = $params['includexmlnamespace'];
                $this->mXslt = $params['xslt'];
 
@@ -71,8 +69,7 @@
                $this->printText(
                        self::recXmlPrint( $this->mRootElemName,
                                $data,
-                               $this->getIsHtml() ? - 2 : null,
-                               $this->mDoubleQuote
+                               $this->getIsHtml() ? - 2 : null
                        )
                );
        }
@@ -117,11 +114,10 @@
         * @param $elemName
         * @param $elemValue
         * @param $indent
-        * @param $doublequote bool
         *
         * @return string
         */
-       public static function recXmlPrint( $elemName, $elemValue, $indent, 
$doublequote = false ) {
+       private static function recXmlPrint( $elemName, $elemValue, $indent ) {
                $retval = '';
                if ( !is_null( $indent ) ) {
                        $indent += 2;
@@ -134,9 +130,6 @@
                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 @@
                        $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 @@
 
        public function getAllowedParams() {
                return array(
-                       'xmldoublequote' => false,
                        'xslt' => null,
                        'includexmlnamespace' => false,
                );
@@ -234,7 +222,6 @@
 
        public function getParamDescription() {
                return array(
-                       'xmldoublequote' => 'If specified, double quotes all 
attributes and content',
                        'xslt' => 'If specified, adds <xslt> 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'

-- 
To view, visit https://gerrit.wikimedia.org/r/58261
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9a4d8c13b78ffd2634d03c8c8b4bbeff69f4bc08
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: PleaseStand <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to