https://www.mediawiki.org/wiki/Special:Code/MediaWiki/103476

Revision: 103476
Author:   hashar
Date:     2011-11-17 16:46:45 +0000 (Thu, 17 Nov 2011)
Log Message:
-----------
(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
        <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!
$

Modified Paths:
--------------
    trunk/phase3/RELEASE-NOTES-1.19
    trunk/phase3/includes/parser/Parser.php
    trunk/phase3/tests/parser/parserTests.txt

Modified: trunk/phase3/RELEASE-NOTES-1.19
===================================================================
--- trunk/phase3/RELEASE-NOTES-1.19     2011-11-17 16:44:44 UTC (rev 103475)
+++ trunk/phase3/RELEASE-NOTES-1.19     2011-11-17 16:46:45 UTC (rev 103476)
@@ -141,6 +141,7 @@
 * (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.

Modified: trunk/phase3/includes/parser/Parser.php
===================================================================
--- trunk/phase3/includes/parser/Parser.php     2011-11-17 16:44:44 UTC (rev 
103475)
+++ trunk/phase3/includes/parser/Parser.php     2011-11-17 16:46:45 UTC (rev 
103476)
@@ -1913,6 +1913,14 @@
 
                                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 ) {

Modified: trunk/phase3/tests/parser/parserTests.txt
===================================================================
--- trunk/phase3/tests/parser/parserTests.txt   2011-11-17 16:44:44 UTC (rev 
103475)
+++ trunk/phase3/tests/parser/parserTests.txt   2011-11-17 16:46:45 UTC (rev 
103476)
@@ -8908,6 +8908,28 @@
 
 !! 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


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to