Skip to content

Commit

Permalink
Escape some values out of precaution, and unsuppress a warning (#486)
Browse files Browse the repository at this point in the history
* phan: Remove suppression of SecurityCheck-XSS

* ManageWikiDeletedWikiPager: Escape some values out of precaution

They can't viably be used for an XSS, but we should escape them anyway.
  • Loading branch information
BlankEclair authored Oct 5, 2024
1 parent e470cfe commit b29c941
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 0 additions & 2 deletions .phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
'PhanNonClassMethodCall',
'PhanImpossibleTypeComparison',
'PhanRedundantConditionInLoop',
// Must work on fixing this and unsuppress it 1 error that was unable to fix and single line suppressing didn't work
'SecurityCheck-XSS',
]
);

Expand Down
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 $value
* @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 b29c941

Please sign in to comment.