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
=== Bug fixes in 1.22 ===
=== API changes in 1.22 ===
=== 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===
=== Languages updated in 1.22===
private $mRootElemName = 'api';
public static $namespace = 'http://www.mediawiki.org/xml/api/';
private $mRootElemName = 'api';
public static $namespace = 'http://www.mediawiki.org/xml/api/';
- private $mDoubleQuote = false;
private $mIncludeNamespace = false;
private $mXslt = null;
private $mIncludeNamespace = false;
private $mXslt = null;
public function execute() {
$params = $this->extractRequestParams();
public function execute() {
$params = $this->extractRequestParams();
- $this->mDoubleQuote = $params['xmldoublequote'];
$this->mIncludeNamespace = $params['includexmlnamespace'];
$this->mXslt = $params['xslt'];
$this->mIncludeNamespace = $params['includexmlnamespace'];
$this->mXslt = $params['xslt'];
$this->printText(
self::recXmlPrint( $this->mRootElemName,
$data,
$this->printText(
self::recXmlPrint( $this->mRootElemName,
$data,
- $this->getIsHtml() ? - 2 : null,
- $this->mDoubleQuote
+ $this->getIsHtml() ? - 2 : null
* @param $elemName
* @param $elemValue
* @param $indent
* @param $elemName
* @param $elemValue
* @param $indent
- * @param $doublequote bool
- public static function recXmlPrint( $elemName, $elemValue, $indent, $doublequote = false ) {
+ public static function recXmlPrint( $elemName, $elemValue, $indent ) {
$retval = '';
if ( !is_null( $indent ) ) {
$indent += 2;
$retval = '';
if ( !is_null( $indent ) ) {
$indent += 2;
if ( is_array( $elemValue ) ) {
if ( isset( $elemValue['*'] ) ) {
$subElemContent = $elemValue['*'];
if ( is_array( $elemValue ) ) {
if ( isset( $elemValue['*'] ) ) {
$subElemContent = $elemValue['*'];
- if ( $doublequote ) {
- $subElemContent = Sanitizer::encodeAttribute( $subElemContent );
- }
unset( $elemValue['*'] );
// Add xml:space="preserve" to the
unset( $elemValue['*'] );
// Add xml:space="preserve" to the
$indElements = array();
$subElements = array();
foreach ( $elemValue as $subElemId => & $subElemValue ) {
$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] );
if ( is_int( $subElemId ) ) {
$indElements[] = $subElemValue;
unset( $elemValue[$subElemId] );
public function getAllowedParams() {
return array(
public function getAllowedParams() {
return array(
- 'xmldoublequote' => false,
'xslt' => null,
'includexmlnamespace' => false,
);
'xslt' => null,
'includexmlnamespace' => false,
);
public function getParamDescription() {
return array(
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'
'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'