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

Revision: 114340
Author:   tstarling
Date:     2012-03-21 01:02:17 +0000 (Wed, 21 Mar 2012)
Log Message:
-----------
Merge r114338 from 1.18: fix for bug 22555: strip markers in padleft etc.

Modified Paths:
--------------
    branches/REL1_17/phase3/RELEASE-NOTES
    branches/REL1_17/phase3/includes/parser/CoreParserFunctions.php
    branches/REL1_17/phase3/includes/parser/Parser.php
    branches/REL1_17/phase3/maintenance/tests/parser/parserTests.txt

Property Changed:
----------------
    branches/REL1_17/phase3/includes/parser/Parser.php
    branches/REL1_17/phase3/maintenance/tests/parser/parserTests.txt

Modified: branches/REL1_17/phase3/RELEASE-NOTES
===================================================================
--- branches/REL1_17/phase3/RELEASE-NOTES       2012-03-21 00:31:54 UTC (rev 
114339)
+++ branches/REL1_17/phase3/RELEASE-NOTES       2012-03-21 01:02:17 UTC (rev 
114340)
@@ -8,27 +8,6 @@
 
 This a maintenance and security release of the MediaWiki 1.17 branch.
 
-=== Security changes ===
-* (bug 33117) prop=revisions allows deleted text to be exposed through cache 
pollution.
-
-=== Changes since 1.17.1 ===
-* (bug 32709) Private Wiki users were always taken to Special:Badtitle on 
login.
-
-== MediaWiki 1.17.1 ==
-
-2011-11-24
-
-This a maintenance and security release of the MediaWiki 1.17 branch.
-
-=== Security changes ===
-* (bug 32276) Skins were generating output using the internal page title which
-  would allow anonymous users to determine wheter a page exists, potentially
-  leaking private data. In fact, the curid and oldid request parameters would
-  allow page titles to be enumerated even when they are not guessable.
-* (bug 32616) action=ajax requests were dispatched to the relevant internal
-  functions without any read permission checks being done. This could lead to
-  data leakage on private wikis.
-
 === Summary of selected changes in 1.17 ===
 
 Selected changes since MediaWiki 1.16 that may be of interest:
@@ -56,6 +35,15 @@
 * The lowest supported version of PHP is now 5.2.3. If necessary, please
   upgrade PHP prior to upgrading MediaWiki.
 
+=== Changes since 1.17.2 ===
+
+* (bug 22555) Remove or skip strip markers from tag hooks like <nowiki> 
in
+  core parser functions which operate on strings, such as padleft.
+
+=== Changes since 1.17.1 ===
+* (bug 33117) prop=revisions allows deleted text to be exposed through cache 
pollution.
+* (bug 32709) Private Wiki users were always taken to Special:Badtitle on 
login.
+
 === Changes since 1.17.0 ===
 
 * (bug 29535) Added missing Creative Commons CC0 icon.
@@ -89,6 +77,13 @@
 * Hardcoded NLS_NUMERIC_CHARACTERS for Oracle DB to prevent type conversion 
errors.
 * Fixed recentchanges FK violation on page delete and cache purge error in 
updater
   for Oracle DB.
+* (bug 32276) Skins were generating output using the internal page title which
+  would allow anonymous users to determine wheter a page exists, potentially
+  leaking private data. In fact, the curid and oldid request parameters would
+  allow page titles to be enumerated even when they are not guessable.
+* (bug 32616) action=ajax requests were dispatched to the relevant internal
+  functions without any read permission checks being done. This could lead to
+  data leakage on private wikis.
 
 === Changes since 1.17.0rc1 ===
 

Modified: branches/REL1_17/phase3/includes/parser/CoreParserFunctions.php
===================================================================
--- branches/REL1_17/phase3/includes/parser/CoreParserFunctions.php     
2012-03-21 00:31:54 UTC (rev 114339)
+++ branches/REL1_17/phase3/includes/parser/CoreParserFunctions.php     
2012-03-21 01:02:17 UTC (rev 114340)
@@ -149,17 +149,21 @@
 
                        // Encode as though it's a wiki page, '_' for ' '.
                        case 'url_wiki':
-                               return wfUrlencode( str_replace( ' ', '_', $s ) 
);
+                               $func = 'wfUrlencode';
+                               $s = str_replace( ' ', '_', $s );
+                               break;
 
                        // Encode for an HTTP Path, '%20' for ' '.
                        case 'url_path':
-                               return rawurlencode( $s );
+                               $func = 'rawurlencode';
+                               break;
 
                        // Encode for HTTP query, '+' for ' '.
                        case 'url_query':
                        default:
-                               return urlencode( $s );
+                               $func = 'urlencode';
                }
+               return $parser->markerSkipCallback( $s, $func );
        }
 
        static function lcfirst( $parser, $s = '' ) {
@@ -174,20 +178,12 @@
 
        static function lc( $parser, $s = '' ) {
                global $wgContLang;
-               if ( is_callable( array( $parser, 'markerSkipCallback' ) ) ) {
-                       return $parser->markerSkipCallback( $s, array( 
$wgContLang, 'lc' ) );
-               } else {
-                       return $wgContLang->lc( $s );
-               }
+               return $parser->markerSkipCallback( $s, array( $wgContLang, 
'lc' ) );
        }
 
        static function uc( $parser, $s = '' ) {
                global $wgContLang;
-               if ( is_callable( array( $parser, 'markerSkipCallback' ) ) ) {
-                       return $parser->markerSkipCallback( $s, array( 
$wgContLang, 'uc' ) );
-               } else {
-                       return $wgContLang->uc( $s );
-               }
+               return $parser->markerSkipCallback( $s, array( $wgContLang, 
'uc' ) );
        }
 
        static function localurl( $parser, $s = '', $arg = null ) { return 
self::urlFunction( 'getLocalURL', $s, $arg ); }
@@ -219,15 +215,17 @@
                }
        }
 
-       static function formatNum( $parser, $num = '', $raw = null) {
-               if ( self::israw( $raw ) ) {
-                       return 
$parser->getFunctionLang()->parseFormattedNumber( $num );
+       static function formatnum( $parser, $num = '', $raw = null) {
+               if ( self::isRaw( $raw ) ) {
+                       $func = array( $parser->getFunctionLang(), 
'parseFormattedNumber' );
                } else {
-                       return $parser->getFunctionLang()->formatNum( $num );
+                       $func = array( $parser->getFunctionLang(), 'formatNum' 
);
                }
+               return $parser->markerSkipCallback( $num, $func );
        }
 
        static function grammar( $parser, $case = '', $word = '' ) {
+               $word = $parser->killMarkers( $word );
                return $parser->getFunctionLang()->convertGrammar( $word, $case 
);
        }
 
@@ -555,7 +553,8 @@
        /**
         * Unicode-safe str_pad with the restriction that $length is forced to 
be <= 500
         */
-       static function pad( $string, $length, $padding = '0', $direction = 
STR_PAD_RIGHT ) {
+       static function pad( $parser, $string, $length, $padding = '0', 
$direction = STR_PAD_RIGHT ) {
+               $padding = $parser->killMarkers( $padding );
                $lengthOfPadding = mb_strlen( $padding );
                if ( $lengthOfPadding == 0 ) return $string;
 
@@ -579,14 +578,15 @@
        }
 
        static function padleft( $parser, $string = '', $length = 0, $padding = 
'0' ) {
-               return self::pad( $string, $length, $padding, STR_PAD_LEFT );
+               return self::pad( $parser, $string, $length, $padding, 
STR_PAD_LEFT );
        }
 
        static function padright( $parser, $string = '', $length = 0, $padding 
= '0' ) {
-               return self::pad( $string, $length, $padding );
+               return self::pad( $parser, $string, $length, $padding );
        }
 
        static function anchorencode( $parser, $text ) {
+               $text = $parser->killMarkers( $text );
                return substr( $parser->guessSectionNameFromWikiText( $text ), 
1);
        }
 

Modified: branches/REL1_17/phase3/includes/parser/Parser.php
===================================================================
--- branches/REL1_17/phase3/includes/parser/Parser.php  2012-03-21 00:31:54 UTC 
(rev 114339)
+++ branches/REL1_17/phase3/includes/parser/Parser.php  2012-03-21 01:02:17 UTC 
(rev 114340)
@@ -5216,6 +5216,16 @@
        }
 
        /**
+        * Remove any strip markers found in the given text.
+        *
+        * @param $text Input string
+        * @return string
+        */
+       function killMarkers( $text ) {
+               return preg_replace( "/{$this->mUniqPrefix}[^\x7f]+" . 
self::MARKER_SUFFIX . '/', '', $text );
+       }
+
+       /**
         * TODO: document
         * @param $data Array
         * @param $intPrefix String unique identifying prefix


Property changes on: branches/REL1_17/phase3/includes/parser/Parser.php
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/REL1_15/phase3/includes/parser/Parser.php:51646
/branches/new-installer/phase3/includes/parser/Parser.php:43664-66004
/branches/sqlite/includes/parser/Parser.php:58211-58321
/branches/wmf-deployment/includes/parser/Parser.php:53381
/trunk/phase3/includes/parser/Parser.php:79324,79732,79785,79915,79957,79964,79990,80687,80697,80755,80771,80773-80774,80779,80816,80833,80841,80999,81006,81011,81101,81105,81138,81141,81146,81149-81150,81166,81171,81430,81488,81496,81554,81561,81589,81600,81611,81620,81622,81640,81648,81650-81652,81729,81765,81778,81812,81854,81890-81894,81896-81898,81900,81955,82297,82307,82309,82312,82315,82337,82391-82392,82403,82411,82446,82457,82466,82473,82475,82478,82482,82486,82518,82530,82538,82547,82550,82565,82572,82608,82696,82748,82836,82853,82858,82871,82938,83005,83015,83046,83114,83153,83173,83270,83284,83374,83390,83392,83402-83403,83410-83411,83420,83461,83463,83476,83489,83496,83586-83587,83798,83814,83876
   + /branches/REL1_15/phase3/includes/parser/Parser.php:51646
/branches/REL1_18/phase3/includes/parser/Parser.php:114338
/branches/new-installer/phase3/includes/parser/Parser.php:43664-66004
/branches/sqlite/includes/parser/Parser.php:58211-58321
/branches/wmf-deployment/includes/parser/Parser.php:53381
/trunk/phase3/includes/parser/Parser.php:79324,79732,79785,79915,79957,79964,79990,80687,80697,80755,80771,80773-80774,80779,80816,80833,80841,80999,81006,81011,81101,81105,81138,81141,81146,81149-81150,81166,81171,81430,81488,81496,81554,81561,81589,81600,81611,81620,81622,81640,81648,81650-81652,81729,81765,81778,81812,81854,81890-81894,81896-81898,81900,81955,82297,82307,82309,82312,82315,82337,82391-82392,82403,82411,82446,82457,82466,82473,82475,82478,82482,82486,82518,82530,82538,82547,82550,82565,82572,82608,82696,82748,82836,82853,82858,82871,82938,83005,83015,83046,83114,83153,83173,83270,83284,83374,83390,83392,83402-83403,83410-83411,83420,83461,83463,83476,83489,83496,83586-83587,83798,83814,83876

Modified: branches/REL1_17/phase3/maintenance/tests/parser/parserTests.txt
===================================================================
--- branches/REL1_17/phase3/maintenance/tests/parser/parserTests.txt    
2012-03-21 00:31:54 UTC (rev 114339)
+++ branches/REL1_17/phase3/maintenance/tests/parser/parserTests.txt    
2012-03-21 01:02:17 UTC (rev 114340)
@@ -8306,6 +8306,87 @@
 !! end
 
 
+!! test
+Strip marker in urlencode
+!! input
+{{urlencode:x<nowiki/>y}}
+{{urlencode:x<nowiki/>y|wiki}}
+{{urlencode:x<nowiki/>y|path}}
+!! result
+<p>xy
+xy
+xy
+</p>
+!! end
+
+!! test
+Strip marker in lc
+!! input
+{{lc:x<nowiki/>y}}
+!! result
+<p>xy
+</p>
+!! end
+
+!! test
+Strip marker in uc
+!! input
+{{uc:x<nowiki/>y}}
+!! result
+<p>XY
+</p>
+!! end
+
+!! test
+Strip marker in formatNum
+!! input
+{{formatnum:1<nowiki/>2}}
+{{formatnum:1<nowiki/>2|R}}
+!! result
+<p>12
+12
+</p>
+!! end
+
+!! test
+Strip marker in grammar
+!! options
+language=fi
+!! input
+{{grammar:elative|foo<nowiki/>bar}}
+!! result
+<p>foobarista
+</p>
+!! end
+
+!! test
+Strip marker in padleft
+!! input
+{{padleft:|2|x<nowiki/>y}}
+!! result
+<p>xy
+</p>
+!! end
+
+!! test
+Strip marker in padright
+!! input
+{{padright:|2|x<nowiki/>y}}
+!! result
+<p>xy
+</p>
+!! end
+
+!! test
+Strip marker in anchorencode
+!! input
+{{anchorencode:x<nowiki/>y}}
+!! result
+<p>xy
+</p>
+!! end
+
+
 TODO:
 more images
 more tables


Property changes on: 
branches/REL1_17/phase3/maintenance/tests/parser/parserTests.txt
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/branches/phpunit-restructure/maintenance/tests/parser/parserTests.txt:72257-72560
/trunk/phase3/maintenance/tests/parser/parserTests.txt:83979,83988-83989,83997-83998,84118,84228,84271,84343,84353,84392,84430
/trunk/phase3/tests/parser/parserTests.txt:83965,87393
   + /branches/REL1_18/phase3/tests/parser/parserTests.txt:114338
/branches/phpunit-restructure/maintenance/tests/parser/parserTests.txt:72257-72560
/trunk/phase3/maintenance/tests/parser/parserTests.txt:83979,83988-83989,83997-83998,84118,84228,84271,84343,84353,84392,84430
/trunk/phase3/tests/parser/parserTests.txt:83965,87393


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

Reply via email to