Tidy Message::parseAsBlock() by enabling tidy in MessageCache
authorC. Scott Ananian <cscott@cscott.net>
Thu, 27 Sep 2018 21:45:04 +0000 (17:45 -0400)
committerC. Scott Ananian <cananian@wikimedia.org>
Wed, 17 Oct 2018 02:43:07 +0000 (02:43 +0000)
We are incrementally removing places where the parser is used with
tidy disabled, since future parsers will not support such operation.

Bug: T198214
Change-Id: I0f417f75a49dfea873e9a2f44d81796a48b9f428

includes/cache/MessageCache.php
tests/phpunit/includes/OutputPageTest.php

index 869f768..5dee0f6 100644 (file)
@@ -198,6 +198,7 @@ class MessageCache {
                                // either.
                                $po = ParserOptions::newFromAnon();
                                $po->setAllowUnsafeRawHtml( false );
+                               $po->setTidy( true );
                                return $po;
                        }
 
@@ -206,6 +207,8 @@ class MessageCache {
                        // from malicious sources. As a precaution, disable
                        // the <html> parser tag when parsing messages.
                        $this->mParserOptions->setAllowUnsafeRawHtml( false );
+                       // For the same reason, tidy the output!
+                       $this->mParserOptions->setTidy( true );
                }
 
                return $this->mParserOptions;
index 53e6f46..b19cd2b 100644 (file)
@@ -1634,9 +1634,8 @@ class OutputPageTest extends MediaWikiTestCase {
                $op = $this->newInstance();
                $this->assertSame( '', $op->getHTML() );
                $op->addWikiMsg( 'parentheses', "<b>a" );
-               // This is known to be bad unbalanced HTML; this will be fixed
-               // by I743f4185a03403f8d9b9db010ff1ee4e9342e062 (T198214)
-               $this->assertSame( "<p>(<b>a)\n</p>", $op->getHTML() );
+               // The input is bad unbalanced HTML, but the output is tidied
+               $this->assertSame( "<p>(<b>a)\n</b></p>", $op->getHTML() );
        }
 
        /**