From 71e27e22deb15069e259771c16550dbc1861e001 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Fri, 9 Dec 2011 10:32:55 +0000 Subject: [PATCH] * Revert r103476, r105161 and implement the fix for bug 32858 (a.k.a. bug 32450) in WikiPage instead. See comment 14 for further rationale. * Clarified release notes. Please write what the new code does, not the bug description. --- RELEASE-NOTES-1.19 | 3 ++- includes/WikiPage.php | 13 ++++++++++++- includes/parser/Parser.php | 6 ------ tests/parser/parserTests.txt | 22 ---------------------- 4 files changed, 14 insertions(+), 30 deletions(-) diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index 69b10874a0..6d56f6e788 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -156,7 +156,8 @@ production. * (bug 32168) Add wfAssembleUrl for use in wfExpandUrl. * (bug 32168) fixed - wfExpandUrl expands dot segments now. * (bug 31535) Upload comments now truncated properly, and don't have brackets. -* (bug 32450) Scripts pages in MediaWiki: namespace parse [[Category:#]] links. +* (bug 32858) Do not register links, categories, etc. from CSS/JS pages in the + database. * (bug 32086) Special:PermanentLink now show an error message when no subpage was specified. * (bug 30368) Special:Newpages now shows the new page name for moved pages. diff --git a/includes/WikiPage.php b/includes/WikiPage.php index ed66879d4d..939eee6180 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -2018,7 +2018,18 @@ class WikiPage extends Page { $edit->newText = $text; $edit->pst = $wgParser->preSaveTransform( $text, $this->mTitle, $user, $popts ); $edit->popts = $this->makeParserOptions( 'canonical' ); - $edit->output = $wgParser->parse( $edit->pst, $this->mTitle, $edit->popts, true, true, $revid ); + + // Bug 32858: For a CSS/JS page, put a blank parser output into the + // prepared edit, so that links etc. won't be registered in the + // database. We could have set $edit->output to false or something if + // we thought of this bug earlier, but now that would break the + // interface with AbuseFilter etc. + if ( $this->mTitle->isCssOrJsPage() || $this->getTitle()->isCssJsSubpage() ) { + $input = ''; + } else { + $input = $edit->pst; + } + $edit->output = $wgParser->parse( $input, $this->mTitle, $edit->popts, true, true, $revid ); $edit->oldText = $this->getRawText(); $this->mPreparedEdit = $edit; diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 33a728bca3..c3d8aa389c 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -1643,12 +1643,6 @@ class Parser { * @private */ function replaceInternalLinks( $s ) { - if( $this->getTitle()->isCssOrJsPage() ) { - # bug 32450 : js and script pages in MediaWiki: namespace do not want - # to get their code or comments altered. Think about js string: - # var foobar = "[[Category:" + $catname + "]]; - return $s; - } $this->mLinkHolders->merge( $this->replaceInternalLinks2( $s ) ); return $s; } diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index d2fb44e48b..9dc3a91056 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -8993,28 +8993,6 @@ title=[[Main Page]] !! end -!! test -Bug 32450: MediaWiki: js pages should ignore Category syntax -!! options -title=[[MediaWiki:bug32450.js]] -!! input -var foo = "[[Category:bug32450]]" -!! result -

var foo = "[[Category:bug32450]]" -

-!! end - -!! test -Bug 32450: MediaWiki: css pages should ignore Category syntax -!! options -title=[[MediaWiki:bug32450.css]] -!! input -/** Css comment: "[[Category:bug32450]]" */ -!! result -

/** Css comment: "[[Category:bug32450]]" */ -

-!! end - TODO: more images more tables -- 2.20.1