From: Antoine Musso Date: Thu, 17 Nov 2011 16:46:45 +0000 (+0000) Subject: (bug 32450) MediaWiki: .js|.css pages parsed [[Category:#]] links X-Git-Tag: 1.31.0-rc.0~26442 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=78562bd14c97b05b38bf12c93ca730a9586cfc91;p=lhc%2Fweb%2Fwiklou.git (bug 32450) MediaWiki: .js|.css pages parsed [[Category:#]] links This patch skip the [[Category:#]] parsing logic when the Title is in NS_MEDIAWIKI and ends with .js or .css. This way the code is kept as is and pages are no more categorized. How to reproduce the issue: $ echo 'var foo = "[[Category:bug32450]]"' \ | php maintenance/parse.php --title MediaWiki:Foobar.js

var foo = ""

$ Note how the text got stripped. After this patch: $ echo 'var foo = "[[Category:bug32450]]"' \ | php maintenance/parse.php --title MediaWiki:Foobar.js

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

$ TEST PLAN: ========== $ php parserTests.php --quiet This is MediaWiki version 1.19alpha (r103473). Reading tests from "tests/parser/parserTests.txt"... Reading tests from "tests/parser/extraParserTests.txt"... Passed 654 of 654 tests (100%)... ALL TESTS PASSED! $ --- diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index 21b86aa8f5..2a4fdfe13e 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -141,6 +141,7 @@ 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 === API changes in 1.19 === * (bug 19838) siprop=interwikimap can now use the interwiki cache. diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 4030d08400..d62258834a 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -1913,6 +1913,14 @@ class Parser { if ( $ns == NS_CATEGORY ) { wfProfileIn( __METHOD__."-category" ); + 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 + "]]; + $s .= "[[$text]]$trail"; + wfProfileOut( __METHOD__."-category" ); + continue; + } $s = rtrim( $s . "\n" ); # bug 87 if ( $wasblank ) { diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index d56726fd13..9a7fd40dfb 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -8908,6 +8908,28 @@ 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