API: Remove XML tag highlighting from non-XML formats
authorKevin Israel <pleasestand@live.com>
Fri, 16 May 2014 16:49:36 +0000 (12:49 -0400)
committerKrinkle <krinklemail@gmail.com>
Tue, 23 Sep 2014 19:44:31 +0000 (19:44 +0000)
Since 926afc65c316, the transformation assumes < and > occur in pairs.
This assumption is invalid for formats such as JSON.

Implementing proper JSON syntax highlighting falls outside the scope
of this workaround and is left for separate changes, likely including
the addition of a hook. That is part of the API roadmap RfC.

https://www.mediawiki.org/wiki/Requests_for_comment/API_roadmap#Changes_to_pretty-printed_HTML_formats

Bug: 65403
Change-Id: Iff8d444c82f7efd2bd1c9f703defc4f0984e8211

RELEASE-NOTES-1.25
includes/api/ApiFormatBase.php

index c8bea32..70f175b 100644 (file)
@@ -25,10 +25,12 @@ changes to languages because of Bugzilla reports.
 === Other changes in 1.25 ===
 * The skin autodiscovery mechanism, deprecated in MediaWiki 1.23, has been
   removed. See https://www.mediawiki.org/wiki/Manual:Skin_autodiscovery for
-  migration guide for creators and users of custom skins that relied on it. 
+  migration guide for creators and users of custom skins that relied on it.
 * Javascript variable 'wgFileCanRotate' now only available on Special:Upload.
 * (bug 56257) Set site logo url in ResourceLoaderSiteModule instead of inline
   styles in the HTML output.
+* (bug 65403) XML tag highlighting is now only performed for formats
+  "xmlfm" and "wddxfm".
 
 == Compatibility ==
 
index 9165ce8..2a57688 100644 (file)
@@ -278,9 +278,12 @@ See the <a href='https://www.mediawiki.org/wiki/API'>complete documentation</a>,
        protected function formatHTML( $text ) {
                // Escape everything first for full coverage
                $text = htmlspecialchars( $text );
-               // encode all comments or tags as safe blue strings
-               $text = str_replace( '&lt;', '<span style="color:blue;">&lt;', $text );
-               $text = str_replace( '&gt;', '&gt;</span>', $text );
+
+               if ( $this->mFormat === 'XML' || $this->mFormat === 'WDDX' ) {
+                       // encode all comments or tags as safe blue strings
+                       $text = str_replace( '&lt;', '<span style="color:blue;">&lt;', $text );
+                       $text = str_replace( '&gt;', '&gt;</span>', $text );
+               }
 
                // identify requests to api.php
                $text = preg_replace( '#^(\s*)(api\.php\?[^ <\n\t]+)$#m', '\1<a href="\2">\2</a>', $text );