From: Yifei He Date: Fri, 22 Dec 2017 03:12:28 +0000 (+0800) Subject: [WikiImporter::notice] use wfDebug instead of echo in notice() X-Git-Tag: 1.31.0-rc.0~1129^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=6db33c1a4b81e46c56457e3a433de12e11eeb3b0 [WikiImporter::notice] use wfDebug instead of echo in notice() Make the default notice implementation of notice() function to send the notice to wfDebug() instead of simply echo to prevent XSS Bug: T177997 Change-Id: I9ffb597e0642afc1603cdd15e2d09c6f2584b448 --- diff --git a/includes/import/WikiImporter.php b/includes/import/WikiImporter.php index 28f3f824e5..ed5ec1a2c2 100644 --- a/includes/import/WikiImporter.php +++ b/includes/import/WikiImporter.php @@ -125,7 +125,9 @@ class WikiImporter { if ( is_callable( $this->mNoticeCallback ) ) { call_user_func( $this->mNoticeCallback, $msg, $params ); } else { # No ImportReporter -> CLI - echo wfMessage( $msg, $params )->text() . "\n"; + // T177997: the command line importers should call setNoticeCallback() + // for their own custom callback to echo the notice + wfDebug( wfMessage( $msg, $params )->text() . "\n" ); } } diff --git a/maintenance/dumpIterator.php b/maintenance/dumpIterator.php index 254f368042..707f4b3c8c 100644 --- a/maintenance/dumpIterator.php +++ b/maintenance/dumpIterator.php @@ -77,6 +77,9 @@ abstract class DumpIterator extends Maintenance { $importer->setRevisionCallback( [ $this, 'handleRevision' ] ); + $importer->setNoticeCallback( function ( $msg, $params ) { + echo wfMessage( $msg, $params )->text() . "\n"; + } ); $this->from = $this->getOption( 'from', null ); $this->count = 0; diff --git a/maintenance/importDump.php b/maintenance/importDump.php index 2923b381dc..918c1ab98b 100644 --- a/maintenance/importDump.php +++ b/maintenance/importDump.php @@ -322,6 +322,9 @@ TEXT $this->pageCount = $nthPage - 1; } $importer->setPageCallback( [ $this, 'reportPage' ] ); + $importer->setNoticeCallback( function ( $msg, $params ) { + echo wfMessage( $msg, $params )->text() . "\n"; + } ); $this->importCallback = $importer->setRevisionCallback( [ $this, 'handleRevision' ] ); $this->uploadCallback = $importer->setUploadCallback( diff --git a/maintenance/renderDump.php b/maintenance/renderDump.php index 68a371c3b2..458556ffce 100644 --- a/maintenance/renderDump.php +++ b/maintenance/renderDump.php @@ -66,6 +66,9 @@ class DumpRenderer extends Maintenance { $importer->setRevisionCallback( [ $this, 'handleRevision' ] ); + $importer->setNoticeCallback( function ( $msg, $params ) { + echo wfMessage( $msg, $params )->text() . "\n"; + } ); $importer->doImport(); diff --git a/maintenance/storage/checkStorage.php b/maintenance/storage/checkStorage.php index 6348e96b21..8f55b88215 100644 --- a/maintenance/storage/checkStorage.php +++ b/maintenance/storage/checkStorage.php @@ -493,6 +493,9 @@ class CheckStorage { MediaWikiServices::getInstance()->getMainConfig() ); $importer->setRevisionCallback( [ $this, 'importRevision' ] ); + $importer->setNoticeCallback( function ( $msg, $params ) { + echo wfMessage( $msg, $params )->text() . "\n"; + } ); $importer->doImport(); }