Only expand `{{...}}` in messages once (part 2)
authorC. Scott Ananian <cscott@cscott.net>
Fri, 26 Oct 2018 16:59:01 +0000 (12:59 -0400)
committerC. Scott Ananian <cananian@wikimedia.org>
Fri, 26 Oct 2018 17:09:42 +0000 (17:09 +0000)
If we're going to call `OutputPage::addWikiTextAs*` or
`OutputPage::parseAs*` to parse the message, we don't need to
pre-expand `{{...}}` markup before passing it to the parser.

Follow up to I2f68f73365df876e6f9d017e4e3ddea39c4a1284.

Bug: T206574
Change-Id: I0ee493207ea80c1caba7e60a31714805dc54c64e

includes/EditPage.php
includes/installer/WebInstaller.php
includes/specials/SpecialVersion.php

index a79b974..bb5d642 100644 (file)
@@ -3945,7 +3945,7 @@ ERROR;
                                #   sitecsspreview, sitejsonpreview, sitejspreview
                                if ( $level && $format ) {
                                        $note = "<div id='mw-{$level}{$format}preview'>" .
-                                               $this->context->msg( "{$level}{$format}preview" )->text() .
+                                               $this->context->msg( "{$level}{$format}preview" )->plain() .
                                                ' ' . $continueEditing . "</div>";
                                }
                        }
@@ -3979,7 +3979,7 @@ ERROR;
                                $this->contentFormat,
                                $ex->getMessage()
                        );
-                       $note .= "\n\n" . $m->parse();
+                       $note .= "\n\n" . $m->plain(); # gets parsed down below
                        $previewHTML = '';
                }
 
index f555c0f..cda8612 100644 (file)
@@ -920,7 +920,7 @@ class WebInstaller extends Installer {
                if ( !isset( $params['labelAttribs'] ) ) {
                        $params['labelAttribs'] = [];
                }
-               $labelText = $params['rawtext'] ?? $this->parse( wfMessage( $params['label'] )->text() );
+               $labelText = $params['rawtext'] ?? $this->parse( wfMessage( $params['label'] )->plain() );
 
                return "<div class=\"config-input-check\">\n" .
                        $params['help'] .
index 4e9245f..b7bd9e3 100644 (file)
@@ -1177,9 +1177,9 @@ class SpecialVersion extends SpecialPage {
                foreach ( $entryPoints as $message => $value ) {
                        $url = wfExpandUrl( $value, PROTO_RELATIVE );
                        $out .= Html::openElement( 'tr' ) .
-                               // ->text() looks like it should be ->parse(), but this function
+                               // ->plain() looks like it should be ->parse(), but this function
                                // returns wikitext, not HTML, boo
-                               Html::rawElement( 'td', [], $this->msg( $message )->text() ) .
+                               Html::rawElement( 'td', [], $this->msg( $message )->plain() ) .
                                Html::rawElement( 'td', [], Html::rawElement( 'code', [], "[$url $value]" ) ) .
                                Html::closeElement( 'tr' );
                }