From: This, that and the other Date: Wed, 23 Dec 2015 09:31:37 +0000 (+1100) Subject: Import: Importing no longer accepts too big revisions X-Git-Tag: 1.31.0-rc.0~8570^2 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=1fa2d7e5d048744be9bf4d3f5e12202d76097c10;p=lhc%2Fweb%2Fwiklou.git Import: Importing no longer accepts too big revisions Make sure the size of imported revisions does not exceed $wgMaxArticleSize. Bug: T73230 Change-Id: I6addace7d0eae565196bba564fbd1e329b681064 --- diff --git a/includes/Import.php b/includes/Import.php index 0999931839..67f7ba50cb 100644 --- a/includes/Import.php +++ b/includes/Import.php @@ -825,6 +825,30 @@ class WikiImporter { * @return bool|mixed */ private function processRevision( $pageInfo, $revisionInfo ) { + global $wgMaxArticleSize; + + // Make sure revisions won't violate $wgMaxArticleSize, which could lead to + // database errors and instability. Testing for revisions with only listed + // content models, as other content models might use serialization formats + // which aren't checked against $wgMaxArticleSize. + if ( ( !isset( $revisionInfo['model'] ) || + in_array( $revisionInfo['model'], array( + 'wikitext', + 'css', + 'json', + 'javascript', + 'text', + '' + ) ) ) && + (int)( strlen( $revisionInfo['text'] ) / 1024 ) > $wgMaxArticleSize + ) { + throw new MWException( 'The text of ' . + ( isset( $revisionInfo['id'] ) ? + "the revision with ID $revisionInfo[id]" : + 'a revision' + ) . " exceeds the maximum allowable size ($wgMaxArticleSize KB)" ); + } + $revision = new WikiRevision( $this->config ); if ( isset( $revisionInfo['id'] ) ) {