r114340 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114339‎ | r114340 | r114341 >
Date:01:02, 21 March 2012
Author:tstarling
Status:ok
Tags:
Comment:
Merge r114338 from 1.18: fix for bug 22555: strip markers in padleft etc.
Modified paths:
  • /branches/REL1_17/phase3/RELEASE-NOTES (modified) (history)
  • /branches/REL1_17/phase3/includes/parser/CoreParserFunctions.php (modified) (history)
  • /branches/REL1_17/phase3/includes/parser/Parser.php (modified) (history)
  • /branches/REL1_17/phase3/maintenance/tests/parser/parserTests.txt (modified) (history)

Diff [purge]

Index: branches/REL1_17/phase3/maintenance/tests/parser/parserTests.txt
@@ -8306,6 +8306,87 @@
83078307 !! end
83088308
83098309
 8310+!! test
 8311+Strip marker in urlencode
 8312+!! input
 8313+{{urlencode:x<nowiki/>y}}
 8314+{{urlencode:x<nowiki/>y|wiki}}
 8315+{{urlencode:x<nowiki/>y|path}}
 8316+!! result
 8317+<p>xy
 8318+xy
 8319+xy
 8320+</p>
 8321+!! end
 8322+
 8323+!! test
 8324+Strip marker in lc
 8325+!! input
 8326+{{lc:x<nowiki/>y}}
 8327+!! result
 8328+<p>xy
 8329+</p>
 8330+!! end
 8331+
 8332+!! test
 8333+Strip marker in uc
 8334+!! input
 8335+{{uc:x<nowiki/>y}}
 8336+!! result
 8337+<p>XY
 8338+</p>
 8339+!! end
 8340+
 8341+!! test
 8342+Strip marker in formatNum
 8343+!! input
 8344+{{formatnum:1<nowiki/>2}}
 8345+{{formatnum:1<nowiki/>2|R}}
 8346+!! result
 8347+<p>12
 8348+12
 8349+</p>
 8350+!! end
 8351+
 8352+!! test
 8353+Strip marker in grammar
 8354+!! options
 8355+language=fi
 8356+!! input
 8357+{{grammar:elative|foo<nowiki/>bar}}
 8358+!! result
 8359+<p>foobarista
 8360+</p>
 8361+!! end
 8362+
 8363+!! test
 8364+Strip marker in padleft
 8365+!! input
 8366+{{padleft:|2|x<nowiki/>y}}
 8367+!! result
 8368+<p>xy
 8369+</p>
 8370+!! end
 8371+
 8372+!! test
 8373+Strip marker in padright
 8374+!! input
 8375+{{padright:|2|x<nowiki/>y}}
 8376+!! result
 8377+<p>xy
 8378+</p>
 8379+!! end
 8380+
 8381+!! test
 8382+Strip marker in anchorencode
 8383+!! input
 8384+{{anchorencode:x<nowiki/>y}}
 8385+!! result
 8386+<p>xy
 8387+</p>
 8388+!! end
 8389+
 8390+
83108391 TODO:
83118392 more images
83128393 more tables
Property changes on: branches/REL1_17/phase3/maintenance/tests/parser/parserTests.txt
___________________________________________________________________
Modified: svn:mergeinfo
83138394 Merged /branches/REL1_18/phase3/tests/parser/parserTests.txt:r114338
Index: branches/REL1_17/phase3/includes/parser/Parser.php
@@ -5216,6 +5216,16 @@
52175217 }
52185218
52195219 /**
 5220+ * Remove any strip markers found in the given text.
 5221+ *
 5222+ * @param $text Input string
 5223+ * @return string
 5224+ */
 5225+ function killMarkers( $text ) {
 5226+ return preg_replace( "/{$this->mUniqPrefix}[^\x7f]+" . self::MARKER_SUFFIX . '/', '', $text );
 5227+ }
 5228+
 5229+ /**
52205230 * TODO: document
52215231 * @param $data Array
52225232 * @param $intPrefix String unique identifying prefix
Property changes on: branches/REL1_17/phase3/includes/parser/Parser.php
___________________________________________________________________
Modified: svn:mergeinfo
52235233 Merged /branches/REL1_18/phase3/includes/parser/Parser.php:r114338
Index: branches/REL1_17/phase3/includes/parser/CoreParserFunctions.php
@@ -149,17 +149,21 @@
150150
151151 // Encode as though it's a wiki page, '_' for ' '.
152152 case 'url_wiki':
153 - return wfUrlencode( str_replace( ' ', '_', $s ) );
 153+ $func = 'wfUrlencode';
 154+ $s = str_replace( ' ', '_', $s );
 155+ break;
154156
155157 // Encode for an HTTP Path, '%20' for ' '.
156158 case 'url_path':
157 - return rawurlencode( $s );
 159+ $func = 'rawurlencode';
 160+ break;
158161
159162 // Encode for HTTP query, '+' for ' '.
160163 case 'url_query':
161164 default:
162 - return urlencode( $s );
 165+ $func = 'urlencode';
163166 }
 167+ return $parser->markerSkipCallback( $s, $func );
164168 }
165169
166170 static function lcfirst( $parser, $s = '' ) {
@@ -174,20 +178,12 @@
175179
176180 static function lc( $parser, $s = '' ) {
177181 global $wgContLang;
178 - if ( is_callable( array( $parser, 'markerSkipCallback' ) ) ) {
179 - return $parser->markerSkipCallback( $s, array( $wgContLang, 'lc' ) );
180 - } else {
181 - return $wgContLang->lc( $s );
182 - }
 182+ return $parser->markerSkipCallback( $s, array( $wgContLang, 'lc' ) );
183183 }
184184
185185 static function uc( $parser, $s = '' ) {
186186 global $wgContLang;
187 - if ( is_callable( array( $parser, 'markerSkipCallback' ) ) ) {
188 - return $parser->markerSkipCallback( $s, array( $wgContLang, 'uc' ) );
189 - } else {
190 - return $wgContLang->uc( $s );
191 - }
 187+ return $parser->markerSkipCallback( $s, array( $wgContLang, 'uc' ) );
192188 }
193189
194190 static function localurl( $parser, $s = '', $arg = null ) { return self::urlFunction( 'getLocalURL', $s, $arg ); }
@@ -219,15 +215,17 @@
220216 }
221217 }
222218
223 - static function formatNum( $parser, $num = '', $raw = null) {
224 - if ( self::israw( $raw ) ) {
225 - return $parser->getFunctionLang()->parseFormattedNumber( $num );
 219+ static function formatnum( $parser, $num = '', $raw = null) {
 220+ if ( self::isRaw( $raw ) ) {
 221+ $func = array( $parser->getFunctionLang(), 'parseFormattedNumber' );
226222 } else {
227 - return $parser->getFunctionLang()->formatNum( $num );
 223+ $func = array( $parser->getFunctionLang(), 'formatNum' );
228224 }
 225+ return $parser->markerSkipCallback( $num, $func );
229226 }
230227
231228 static function grammar( $parser, $case = '', $word = '' ) {
 229+ $word = $parser->killMarkers( $word );
232230 return $parser->getFunctionLang()->convertGrammar( $word, $case );
233231 }
234232
@@ -555,7 +553,8 @@
556554 /**
557555 * Unicode-safe str_pad with the restriction that $length is forced to be <= 500
558556 */
559 - static function pad( $string, $length, $padding = '0', $direction = STR_PAD_RIGHT ) {
 557+ static function pad( $parser, $string, $length, $padding = '0', $direction = STR_PAD_RIGHT ) {
 558+ $padding = $parser->killMarkers( $padding );
560559 $lengthOfPadding = mb_strlen( $padding );
561560 if ( $lengthOfPadding == 0 ) return $string;
562561
@@ -579,14 +578,15 @@
580579 }
581580
582581 static function padleft( $parser, $string = '', $length = 0, $padding = '0' ) {
583 - return self::pad( $string, $length, $padding, STR_PAD_LEFT );
 582+ return self::pad( $parser, $string, $length, $padding, STR_PAD_LEFT );
584583 }
585584
586585 static function padright( $parser, $string = '', $length = 0, $padding = '0' ) {
587 - return self::pad( $string, $length, $padding );
 586+ return self::pad( $parser, $string, $length, $padding );
588587 }
589588
590589 static function anchorencode( $parser, $text ) {
 590+ $text = $parser->killMarkers( $text );
591591 return substr( $parser->guessSectionNameFromWikiText( $text ), 1);
592592 }
593593
Index: branches/REL1_17/phase3/RELEASE-NOTES
@@ -8,27 +8,6 @@
99
1010 This a maintenance and security release of the MediaWiki 1.17 branch.
1111
12 -=== Security changes ===
13 -* (bug 33117) prop=revisions allows deleted text to be exposed through cache pollution.
14 -
15 -=== Changes since 1.17.1 ===
16 -* (bug 32709) Private Wiki users were always taken to Special:Badtitle on login.
17 -
18 -== MediaWiki 1.17.1 ==
19 -
20 -2011-11-24
21 -
22 -This a maintenance and security release of the MediaWiki 1.17 branch.
23 -
24 -=== Security changes ===
25 -* (bug 32276) Skins were generating output using the internal page title which
26 - would allow anonymous users to determine wheter a page exists, potentially
27 - leaking private data. In fact, the curid and oldid request parameters would
28 - allow page titles to be enumerated even when they are not guessable.
29 -* (bug 32616) action=ajax requests were dispatched to the relevant internal
30 - functions without any read permission checks being done. This could lead to
31 - data leakage on private wikis.
32 -
3312 === Summary of selected changes in 1.17 ===
3413
3514 Selected changes since MediaWiki 1.16 that may be of interest:
@@ -56,6 +35,15 @@
5736 * The lowest supported version of PHP is now 5.2.3. If necessary, please
5837 upgrade PHP prior to upgrading MediaWiki.
5938
 39+=== Changes since 1.17.2 ===
 40+
 41+* (bug 22555) Remove or skip strip markers from tag hooks like &lt;nowiki&gt; in
 42+ core parser functions which operate on strings, such as padleft.
 43+
 44+=== Changes since 1.17.1 ===
 45+* (bug 33117) prop=revisions allows deleted text to be exposed through cache pollution.
 46+* (bug 32709) Private Wiki users were always taken to Special:Badtitle on login.
 47+
6048 === Changes since 1.17.0 ===
6149
6250 * (bug 29535) Added missing Creative Commons CC0 icon.
@@ -89,6 +77,13 @@
9078 * Hardcoded NLS_NUMERIC_CHARACTERS for Oracle DB to prevent type conversion errors.
9179 * Fixed recentchanges FK violation on page delete and cache purge error in updater
9280 for Oracle DB.
 81+* (bug 32276) Skins were generating output using the internal page title which
 82+ would allow anonymous users to determine wheter a page exists, potentially
 83+ leaking private data. In fact, the curid and oldid request parameters would
 84+ allow page titles to be enumerated even when they are not guessable.
 85+* (bug 32616) action=ajax requests were dispatched to the relevant internal
 86+ functions without any read permission checks being done. This could lead to
 87+ data leakage on private wikis.
9388
9489 === Changes since 1.17.0rc1 ===
9590

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r114231Fixed a few "strip tag exposed" bugs....tstarling04:39, 20 March 2012
r114338Backported the bug 22555 part of r114232 and cleaned up RELEASE-NOTES-1.18tstarling00:31, 21 March 2012

Status & tagging log