(bug 32450) MediaWiki: .js|.css pages parsed [[Category:#]] links
authorAntoine Musso <hashar@users.mediawiki.org>
Thu, 17 Nov 2011 16:46:45 +0000 (16:46 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Thu, 17 Nov 2011 16:46:45 +0000 (16:46 +0000)
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
<p>var foo = ""
</p>
$

Note how the text got stripped.

After this patch:

$ echo 'var foo = "[[Category:bug32450]]"' \
| php maintenance/parse.php --title MediaWiki:Foobar.js
<p>var foo = "[[Category:bug32450]]"
</p>
$

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!
$

RELEASE-NOTES-1.19
includes/parser/Parser.php
tests/parser/parserTests.txt

index 21b86aa..2a4fdfe 100644 (file)
@@ -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.
index 4030d08..d622588 100644 (file)
@@ -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 ) {
index d56726f..9a7fd40 100644 (file)
@@ -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
+<p>var foo = "[[Category:bug32450]]"
+</p>
+!! end
+
+!! test
+Bug 32450: MediaWiki: css pages should ignore Category syntax
+!! options
+title=[[MediaWiki:bug32450.css]]
+!! input
+/** Css comment: "[[Category:bug32450]]" */
+!! result
+<p>/** Css comment: "[[Category:bug32450]]" */
+</p>
+!! end
+
 TODO:
 more images
 more tables