r10835 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r10834‎ | r10835 | r10836 >
Date:23:50, 29 August 2005
Author:vibber
Status:old
Tags:
Comment:
Bump to 1.4.9:
* Security fix for <math>
* Security fix for tables
Modified paths:
  • /branches/REL1_4/phase3/RELEASE-NOTES (modified) (history)
  • /branches/REL1_4/phase3/includes/Article.php (modified) (history)
  • /branches/REL1_4/phase3/includes/DefaultSettings.php (modified) (history)
  • /branches/REL1_4/phase3/includes/Parser.php (modified) (history)
  • /branches/REL1_4/phase3/maintenance/parserTests.php (modified) (history)
  • /branches/REL1_4/phase3/maintenance/parserTests.txt (modified) (history)

Diff [purge]

Index: branches/REL1_4/phase3/maintenance/parserTests.txt
@@ -2141,6 +2141,46 @@
21422142
21432143 !! end
21442144
 2145+
 2146+!! test
 2147+Math section safety when disabled
 2148+!! input
 2149+<math><script>alert(document.cookies);</script></math>
 2150+!! result
 2151+<p>&lt;math&gt;&lt;script&gt;alert(document.cookies);&lt;/script&gt;&lt;/math&gt;
 2152+</p>
 2153+!! end
 2154+
 2155+
 2156+!! test
 2157+Table attribute legitimate extension
 2158+!! input
 2159+{|
 2160+!+ style="<nowiki>color:blue</nowiki>"| status
 2161+|}
 2162+!! result
 2163+<table >
 2164+<tr >
 2165+<th style="color:blue"> status
 2166+</th></tr></table>
 2167+
 2168+!!end
 2169+
 2170+!! test
 2171+Table attribute safety
 2172+!! input
 2173+{|
 2174+!+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"| status
 2175+|}
 2176+!! result
 2177+<table >
 2178+<tr >
 2179+<th > status
 2180+</th></tr></table>
 2181+
 2182+!! end
 2183+
 2184+
21452185 TODO:
21462186 more images
21472187 more tables
Index: branches/REL1_4/phase3/maintenance/parserTests.php
@@ -299,6 +299,7 @@
300300 'wgMaxTocLevel' => 999,
301301 'wgCapitalLinks' => true,
302302 'wgNoFollowLinks' => true,
 303+ 'wgUseTeX' => false,
303304 );
304305 $this->savedGlobals = array();
305306 foreach( $settings as $var => $val ) {
Index: branches/REL1_4/phase3/includes/Article.php
@@ -232,6 +232,7 @@
233233 $striparray=array();
234234 $parser=new Parser();
235235 $parser->mOutputType=OT_WIKI;
 236+ $parser->mOptions = new ParserOptions();
236237 $striptext=$parser->strip($text, $striparray, true);
237238
238239 # now that we can be sure that no pseudo-sections are in the source,
@@ -940,6 +941,7 @@
941942 $striparray=array();
942943 $parser=new Parser();
943944 $parser->mOutputType=OT_WIKI;
 945+ $parser->mOptions = new ParserOptions();
944946 $oldtext=$parser->strip($oldtext, $striparray, true);
945947
946948 # now that we can be sure that no pseudo-sections are in the source,
Index: branches/REL1_4/phase3/includes/Parser.php
@@ -305,16 +305,14 @@
306306 }
307307
308308 # math
309 - $text = Parser::extractTags('math', $text, $math_content, $uniq_prefix);
310 - foreach( $math_content as $marker => $content ){
311 - if( $render ) {
312 - if( $this->mOptions->getUseTeX() ) {
 309+ if( $this->mOptions->getUseTeX() ) {
 310+ $text = Parser::extractTags('math', $text, $math_content, $uniq_prefix);
 311+ foreach( $math_content as $marker => $content ){
 312+ if( $render ) {
313313 $math_content[$marker] = renderMath( $content );
314314 } else {
315 - $math_content[$marker] = '&lt;math&gt;'.$content.'&lt;math&gt;';
 315+ $math_content[$marker] = '<math>'.$content.'</math>';
316316 }
317 - } else {
318 - $math_content[$marker] = '<math>'.$content.'</math>';
319317 }
320318 }
321319
@@ -666,8 +664,11 @@
667665 $fc = substr ( $x , 0 , 1 ) ;
668666 if ( preg_match( '/^(:*)\{\|(.*)$/', $x, $matches ) ) {
669667 $indent_level = strlen( $matches[1] );
 668+
 669+ $attributes = $this->unstripForHTML( $matches[2] );
 670+
670671 $t[$k] = str_repeat( '<dl><dd>', $indent_level ) .
671 - '<table ' . $this->fixTagAttributes ( $matches[2] ) . '>' ;
 672+ '<table ' . $this->fixTagAttributes ( $attributes ) . '>' ;
672673 array_push ( $td , false ) ;
673674 array_push ( $ltd , '' ) ;
674675 array_push ( $tr , false ) ;
@@ -694,7 +695,8 @@
695696 array_push ( $tr , false ) ;
696697 array_push ( $td , false ) ;
697698 array_push ( $ltd , '' ) ;
698 - array_push ( $ltr , $this->fixTagAttributes ( $x ) ) ;
 699+ $attributes = $this->unstripForHTML( $x );
 700+ array_push ( $ltr , $this->fixTagAttributes ( $attributes ) ) ;
699701 }
700702 else if ( '|' == $fc || '!' == $fc || '|+' == substr ( $x , 0 , 2 ) ) { # Caption
701703 # $x is a table row
@@ -736,7 +738,10 @@
737739 }
738740 if ( count ( $y ) == 1 )
739741 $y = "{$z}<{$l}>{$y[0]}" ;
740 - else $y = $y = "{$z}<{$l} ".$this->fixTagAttributes($y[0]).">{$y[1]}" ;
 742+ else {
 743+ $attributes = $this->unstripForHTML( $y[0] );
 744+ $y = "{$z}<{$l} ".$this->fixTagAttributes($attributes).">{$y[1]}" ;
 745+ }
741746 $t[$k] .= $y ;
742747 array_push ( $td , true ) ;
743748 }
@@ -3260,6 +3265,11 @@
32613266 */
32623267 function attributeStripCallback( &$text, $args ) {
32633268 $text = $this->replaceVariables( $text, $args );
 3269+ $text = $this->unstripForHTML( $text );
 3270+ return $text;
 3271+ }
 3272+
 3273+ function unstripForHTML( $text ) {
32643274 $text = $this->unstrip( $text, $this->mStripState );
32653275 $text = $this->unstripNoWiki( $text, $this->mStripState );
32663276 return $text;
Index: branches/REL1_4/phase3/includes/DefaultSettings.php
@@ -19,7 +19,7 @@
2020 * MediaWiki version number
2121 * @global string $wgVersion
2222 */
23 -$wgVersion = '1.4.8';
 23+$wgVersion = '1.4.9';
2424
2525 /**
2626 * Name of the site.
Index: branches/REL1_4/phase3/RELEASE-NOTES
@@ -3,6 +3,23 @@
44 Security reminder: MediaWiki does not require PHP's register_globals
55 setting since version 1.2.0. If you have it on, turn it *off* if you can.
66
 7+== MediaWiki 1.4.9 ==
 8+
 9+(released 2005-08-29)
 10+
 11+MediaWiki 1.4.9 is a security maintenance release. It corrects two cross-site
 12+scripting security bugs:
 13+
 14+* <math> tags were handled incorrectly when TeX rendering support is off,
 15+ as in the default configuration.
 16+* Extension or <nowiki> sections in Wiki table syntax could bypass HTML
 17+ style attribute restrictions for cross-site scripting attacks against
 18+ Microsoft Internet Explorer
 19+
 20+Wikis where the optional math support has been *enabled* are not vulnerable
 21+to the first, but are vulnerable to the second.
 22+
 23+
724 == MediaWiki 1.4.8 ==
825
926 (released 2005-08-23)
@@ -741,6 +758,12 @@
742759 * (bug 3244) Fix remote image loading hack, JavaScript injection on MSIE
743760
744761
 762+=== 1.4.9 changes ===
 763+
 764+* Security fix for <math>
 765+* Security fix for tables
 766+
 767+
745768 === Caveats ===
746769
747770 Some output, particularly involving user-supplied inline HTML, may not

Status & tagging log