Fix not parsed message on Special:Import
authorFlorian Schmidt <florian.schmidt.stargatewissen@gmail.com>
Tue, 1 Aug 2017 20:43:51 +0000 (22:43 +0200)
committerFlorian Schmidt <florian.schmidt.stargatewissen@gmail.com>
Tue, 1 Aug 2017 20:43:51 +0000 (22:43 +0200)
If session data is lost between the transactions (read: the csrf token
does not match), the error message contains some wiki markup as well as
HTML. However, unfortunately, SpecialImport uses $out->wrapWikiMsg() in
combination with an error message (with wiki markup and HTML) wrapped as
a parameter of another message. This results in an escaped paramater and
it is not parsed correctly, which leads in wiki markup send to the user.

This change fixes that issue by parsing the message directly.

Bug: T172114
Change-Id: If49a600173c44d098f25d6e2a9b87b7b7bf3ee2a

includes/specials/SpecialImport.php
languages/i18n/en.json

index a827e89..beb454d 100644 (file)
@@ -173,10 +173,8 @@ class SpecialImport extends SpecialPage {
 
                $out = $this->getOutput();
                if ( !$source->isGood() ) {
-                       $out->wrapWikiMsg(
-                               "<p class=\"error\">\n$1\n</p>",
-                               [ 'importfailed', $source->getWikiText() ]
-                       );
+                       $out->addWikiText( "<p class=\"error\">\n" .
+                               $this->msg( 'importfailed', $source->getWikiText() )->parse() . "\n</p>" );
                } else {
                        $importer = new WikiImporter( $source->value, $this->getConfig() );
                        if ( !is_null( $this->namespace ) ) {
index 8c295b2..4929f55 100644 (file)
        "import-nonewrevisions": "No revisions imported (all were either already present, or skipped due to errors).",
        "xml-error-string": "$1 at line $2, col $3 (byte $4): $5",
        "import-upload": "Upload XML data",
-       "import-token-mismatch": "Loss of session data.\n\nYou might have been logged out. <strong>Please verify that you're still logged in and try again</strong>.\nIf it still does not work, try [[Special:UserLogout|logging out]] and logging back in, and check that your browser allows cookies from this site.",
+       "import-token-mismatch": "Loss of session data.\n\nYou might have been logged out. '''Please verify that you're still logged in and try again'''.\nIf it still does not work, try [[Special:UserLogout|logging out]] and logging back in, and check that your browser allows cookies from this site.",
        "import-invalid-interwiki": "Cannot import from the specified wiki.",
        "import-error-edit": "Page \"$1\" was not imported because you are not allowed to edit it.",
        "import-error-create": "Page \"$1\" was not imported because you are not allowed to create it.",