Skip to content

Commit

Permalink
ManageWikiDeletedWikiPager: Escape some values out of precaution
Browse files Browse the repository at this point in the history
They can't viably be used for an XSS, but we should escape them anyway.
  • Loading branch information
BlankEclair committed Oct 5, 2024
1 parent e4b770b commit 3aeec36
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions includes/Helpers/ManageWikiDeletedWikiPager.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,34 @@ public function getFieldNames() {
return $headers;
}

/**
* Safely HTML-escape $value
*
* @param string $name
* @return string
*/
private static function escape( $value ) {
return htmlspecialchars( $value, ENT_QUOTES );
}

public function formatValue( $name, $value ) {
$row = $this->mCurrentRow;

switch ( $name ) {
case 'wiki_dbname':
$formatted = $row->wiki_dbname;
$formatted = $this->escape( $row->wiki_dbname );
break;
case 'wiki_creation':
$formatted = wfTimestamp( TS_RFC2822, (int)$row->wiki_creation );
$formatted = $this->escape( wfTimestamp( TS_RFC2822, (int)$row->wiki_creation ) );
break;
case 'wiki_deleted_timestamp':
$formatted = wfTimestamp( TS_RFC2822, (int)$row->wiki_deleted_timestamp );
$formatted = $this->escape( wfTimestamp( TS_RFC2822, (int)$row->wiki_deleted_timestamp ) );
break;
case 'wiki_deleted':
$formatted = Linker::makeExternalLink( SpecialPage::getTitleFor( 'ManageWiki' )->getFullURL() . '/core/' . $row->wiki_dbname, $this->msg( 'managewiki-label-goto' )->text() );
break;
default:
$formatted = "Unable to format $name";
$formatted = $this->escape( "Unable to format $name" );
break;
}
return $formatted;
Expand Down

0 comments on commit 3aeec36

Please sign in to comment.