r14585 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r14584‎ | r14585 | r14586 >
Date:06:21, 6 June 2006
Author:brion
Status:old
Tags:
Comment:
* Edit security precautions in raw HTML mode, etc
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/EditPage.php (modified) (history)
  • /trunk/phase3/languages/Messages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/EditPage.php
@@ -23,7 +23,7 @@
2424 var $formtype;
2525 var $firsttime;
2626 var $lastDelete;
27 - var $mTokenOk = true;
 27+ var $mTokenOk = false;
2828 var $tooBig = false;
2929 var $kblength = false;
3030 var $missingComment = false;
@@ -358,19 +358,17 @@
359359 $this->preview = $request->getCheck( 'wpPreview' ) || $request->getCheck( 'wpLivePreview' );
360360 $this->diff = $request->getCheck( 'wpDiff' );
361361
362 - if( !$this->preview ) {
363 - if ( $this->tokenOk( $request ) ) {
364 - # Some browsers will not report any submit button
365 - # if the user hits enter in the comment box.
366 - # The unmarked state will be assumed to be a save,
367 - # if the form seems otherwise complete.
368 - wfDebug( "$fname: Passed token check.\n" );
369 - } else {
370 - # Page might be a hack attempt posted from
371 - # an external site. Preview instead of saving.
372 - wfDebug( "$fname: Failed token check; forcing preview\n" );
373 - $this->preview = true;
374 - }
 362+ if ( $this->tokenOk( $request ) ) {
 363+ # Some browsers will not report any submit button
 364+ # if the user hits enter in the comment box.
 365+ # The unmarked state will be assumed to be a save,
 366+ # if the form seems otherwise complete.
 367+ wfDebug( "$fname: Passed token check.\n" );
 368+ } else {
 369+ # Page might be a hack attempt posted from
 370+ # an external site. Preview instead of saving.
 371+ wfDebug( "$fname: Failed token check; forcing preview\n" );
 372+ $this->preview = true;
375373 }
376374 }
377375 $this->save = ! ( $this->preview OR $this->diff );
@@ -1115,7 +1113,7 @@
11161114 # For a bit more sophisticated detection of blank summaries, hash the
11171115 # automatic one and pass that in a hidden field.
11181116 $autosumm = $this->autoSumm ? $this->autoSumm : md5( $this->summary );
1119 - $wgOut->addHTML( "<input type=\"hidden\" name=\"wpAutoSummary\" value=\"$autosumm\" />\n" );
 1117+ $wgOut->addHtml( wfHidden( 'wpAutoSummary', $autosumm ) );
11201118
11211119 if ( $this->isConflict ) {
11221120 require_once( "DifferenceEngine.php" );
@@ -1276,9 +1274,17 @@
12771275 $parserOptions = ParserOptions::newFromUser( $wgUser );
12781276 $parserOptions->setEditSection( false );
12791277
 1278+ global $wgRawHtml;
 1279+ if( $wgRawHtml && !$this->mTokenOk ) {
 1280+ // Could be an offsite preview attempt. This is very unsafe if
 1281+ // HTML is enabled, as it could be an attack.
 1282+ return $wgOut->parse( "<div class='previewnote'>" .
 1283+ wfMsg( 'session_fail_preview_html' ) . "</div>" );
 1284+ }
 1285+
12801286 # don't parse user css/js, show message about preview
12811287 # XXX: stupid php bug won't let us use $wgTitle->isCssJsSubpage() here
1282 -
 1288+
12831289 if ( $this->isCssJsSubpage ) {
12841290 if(preg_match("/\\.css$/", $wgTitle->getText() ) ) {
12851291 $previewtext = wfMsg('usercsspreview');
Index: trunk/phase3/RELEASE-NOTES
@@ -438,6 +438,7 @@
439439 * Fix for HTML headings improperly not detected with preceding/following text
440440 * Section extraction and replacement functions merged into one implementation
441441 on the Parser object, so they can't get out of sync with each other.
 442+* Edit security precautions in raw HTML mode, etc
442443
443444
444445 == Compatibility ==
Index: trunk/phase3/languages/Messages.php
@@ -513,6 +513,13 @@
514514 Please try again. If it still doesn\'t work, try logging out and logging back in.</strong>',
515515 'previewconflict' => 'This preview reflects the text in the upper
516516 text editing area as it will appear if you choose to save.',
 517+'session_fail_preview_html' => '<strong>Sorry! We could not process your edit due to a loss of session data.</strong>
 518+
 519+\'\'Because this wiki has raw HTML enabled, the preview is hidden as a precaution against JavaScript attacks.\'\'
 520+
 521+<strong>If this is a legitimate edit attempt, please try again. If it still doesn\'t work, try logging out and logging back in.</strong>',
 522+'previewconflict' => 'This preview reflects the text in the upper
 523+text editing area as it will appear if you choose to save.',
517524 'importing' => 'Importing $1',
518525 'editing' => 'Editing $1',
519526 'editingsection' => 'Editing $1 (section)',

Status & tagging log