r100612 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100611‎ | r100612 | r100613 >
Date:16:19, 24 October 2011
Author:platonides
Status:resolved
Tags:
Comment:
Follow up r100520: Also escape message parameters
Modified paths:
  • /trunk/extensions/RecordAdmin/RecordAdmin_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RecordAdmin/RecordAdmin_body.php
@@ -1,4 +1,4 @@
2 -<?php
 2+w<?php
33 class RecordAdmin {
44
55 var $form = '';
@@ -325,7 +325,7 @@
326326 $table = "<table$id class='recordadmin$sortable $type-record'>\n<tr>";
327327 $th = array(
328328 'select' => "<th class='col-select'>" . wfMsgHtml( 'recordadmin-select' ) . "$br</th>",
329 - 'title' => "<th class='col0 col-title'>" . wfMsgHtml( 'recordadmin-title', $type ) . "$br</th>",
 329+ 'title' => "<th class='col0 col-title'>" . wfMsgHtml( 'recordadmin-title', htmlspecialchars( $type ) ) . "$br</th>",
330330 'actions' => "<th class='col1 col-actions'>" . wfMsgHtml( 'recordadmin-actions' ) . "$br</th>",
331331 'created' => "<th class='col2 col-created'>" . wfMsgHtml( 'recordadmin-created' ) . "$br</th>",
332332 'modified' => "<th class='col3 col-modified'>" . wfMsgHtml( 'recordadmin-modified' ) . "$br</th>"
@@ -353,13 +353,13 @@
354354 $tmp = array();
355355 foreach( $records as $k1 => $v1 ) {
356356 if( empty( $k1 ) ) {
357 - $k1 = wfMsgHtml( 'recordadmin-notset', $groupby[0] );
 357+ $k1 = htmlspecialchars( wfMsg( 'recordadmin-notset', $groupby[0] ) );
358358 }
359359 $tmp[] = "$td<h2>$k1</h2></td>\n";
360360 foreach( $v1 as $k2 => $v2 ) {
361361 if( isset( $groupby[1] ) ) {
362362 if( empty( $k2 ) ) {
363 - $k2 = wfMsgHtml( 'recordadmin-notset', $groupby[1] );
 363+ $k2 = htmlspecialchars( wfMsg( 'recordadmin-notset', $groupby[1] ) );
364364 }
365365 $tmp[] = "$td<h3>$k2</h3></td>\n";
366366 foreach( $v2 as $v3 ) $tmp[] = $v3;
@@ -551,7 +551,7 @@
552552 else {
553553
554554 # Create a red link to the form if it doesn't exist
555 - $form = '<b>' . wfMsgHtml( 'recordadmin-noform', $type ) . '</b>'
 555+ $form = '<b>' . wfMsgHtml( 'recordadmin-noform', htmlspecialchars( $type ) ) . '</b>'
556556 . '<br /><a href="' . $title->getLocalURL( 'action=edit' )
557557 . '">(' . wfMsgHtml( 'recordadmin-createlink' ) . ')</a><br />';
558558 }
@@ -884,19 +884,19 @@
885885 $ttitle = Title::newFromtext( $newtype, NS_TEMPLATE );
886886 $ftitle = Title::newFromtext( $newtype, NS_FORM );
887887 if( !is_object( $ttitle ) || !is_object( $ftitle ) ) {
888 - $wgOut->addHTML( "<div class='errorbox'>" . wfMsgHtml( 'recordadmin-createerror', $rtype ) . "</div>\n" );
 888+ $wgOut->addHTML( "<div class='errorbox'>" . wfMsgHtml( 'recordadmin-createerror', htmlspecialchars( $rtype ) ) . "</div>\n" );
889889 }
890890 $tttext = $ttitle->getPrefixedText();
891891 $fttext = $ftitle->getPrefixedText();
892892
893893 # check if the template already exists
894894 if( $ttitle->exists() ) {
895 - $wgOut->addHTML( "<div class='errorbox'>" . wfMsgHtml( 'recordadmin-alreadyexist', $tttext ) . "</div>\n" );
 895+ $wgOut->addHTML( "<div class='errorbox'>" . wfMsgHtml( 'recordadmin-alreadyexist', htmlspecialchars( $tttext ) ) . "</div>\n" );
896896 }
897897
898898 # check if the form already exists
899899 elseif( $ftitle->exists() ) {
900 - $wgOut->addHTML( "<div class='errorbox'>" . wfMsgHtml( 'recordadmin-alreadyexist', $fttext ) . "</div>\n" );
 900+ $wgOut->addHTML( "<div class='errorbox'>" . wfMsgHtml( 'recordadmin-alreadyexist', htmlspecialchars( $fttext ) ) . "</div>\n" );
901901 }
902902
903903 # Attempt to create the template and form
@@ -918,11 +918,11 @@
919919 $text = "<html>\n\t<form>\n\t\t<table>\n\t\t$link\n\t\t</table>\n\t</form>\n</html>";
920920 $article = new Article( $ftitle );
921921 $success = $article->doEdit( $text, $summary, EDIT_NEW );
922 - if( !$success ) $wgOut->addHTML( "<div class='errorbox'>" . wfMsgHtml( 'recordadmin-createerror', $fttext ) . "</div>\n" );
923 - } else $wgOut->addHTML( "<div class='errorbox'>" . wfMsgHtml( 'recordadmin-createerror', $tttext ) . "</div>\n" );
 922+ if( !$success ) $wgOut->addHTML( "<div class='errorbox'>" . wfMsgHtml( 'recordadmin-createerror', htmlspecialchars( $fttext ) ) . "</div>\n" );
 923+ } else $wgOut->addHTML( "<div class='errorbox'>" . wfMsgHtml( 'recordadmin-createerror', htmlspecialchars( $tttext ) ) . "</div>\n" );
924924
925925 # Report success
926 - if( $success ) $wgOut->addHTML( "<div class='successbox'>" . wfMsgHtml( 'recordadmin-createsuccess', $rtype ) . "</div>\n" );
 926+ if( $success ) $wgOut->addHTML( "<div class='successbox'>" . wfMsgHtml( 'recordadmin-createsuccess', htmlspecialchars( $rtype ) ) . "</div>\n" );
927927 }
928928 }
929929

Follow-up revisions

RevisionCommit summaryAuthorDate
r100993Remove extraneous w, inserted in r100612.platonides16:04, 27 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r100520Escape htmlplatonides22:19, 22 October 2011

Status & tagging log