Don't run the non-Tidy "bug 2702" hack unless Tidy is really missing
authorTim Starling <tstarling@wikimedia.org>
Thu, 7 Jul 2016 23:42:50 +0000 (09:42 +1000)
committerTim Starling <tstarling@wikimedia.org>
Wed, 27 Jul 2016 04:47:36 +0000 (14:47 +1000)
We have two hacks which are used when Tidy is not available: one in
Sanitizer::removeHTMLtags(), and the second here as a late Parser pass
equivalent to Tidy itself. But the Sanitizer one was enabled only if
MWTidy::isEnabled() returned false, whereas the Parser one was enabled
also when tidy was disabled in ParserOptions. This patch makes them both
consistent, it enables the bug 2702 hack only when MWTidy::isEnabled()
returns false, and when Tidy is disabled in parser options, the output
is simply passed through.

This allows tidying to be done separately on the ParserOutput, as is
required by the proposed ParserMigration extension (I24d0776a933fa3f).

Eventually the bug 2702 hack will be removed in favour of a pure-PHP
HTML 5 parser, but it looks like it is too early for that.

Change-Id: I94be6c9dec531c23ef80cb36732243bd6858bf22

RELEASE-NOTES-1.28
includes/parser/Parser.php

index 608bc56..5b77ac2 100644 (file)
@@ -85,6 +85,8 @@ changes to languages because of Phabricator reports.
   were replaced by HtmlPageLinkRendererBegin and HtmlPageLinkRendererEnd
   respectively. See docs/hooks.txt for the specific changes needed for those hooks.
 * The 'ParserLimitReportFormat' hook was removed.
+* Disabled "bug 2702" HTML tidying of parsed UI messages on wikis where Tidy is
+  disabled.
 
 == Compatibility ==
 
index e57ec8e..f9eea48 100644 (file)
@@ -1341,8 +1341,10 @@ class Parser {
 
                $text = Sanitizer::normalizeCharReferences( $text );
 
-               if ( MWTidy::isEnabled() && $this->mOptions->getTidy() ) {
-                       $text = MWTidy::tidy( $text );
+               if ( MWTidy::isEnabled() ) {
+                       if ( $this->mOptions->getTidy() ) {
+                               $text = MWTidy::tidy( $text );
+                       }
                } else {
                        # attempt to sanitize at least some nesting problems
                        # (bug #2702 and quite a few others)