Fix Phan suppression

The SecurityCheck-XSS violation occurred because, in renderFeed(),
the $renderedFeed variable contains both wikitext (tainted) and
HTML (safe) at different points in the function, and Phan is unable
to disentangle that. Splitting it into two variables allows Phan to
validate the rest of the code just fine.

Change-Id: I4da446b869349f06fc0fc40816d44cee390c49a6
This commit is contained in:
Bartosz Dziewoński 2024-09-19 07:43:52 +02:00
parent 2cc29f25a0
commit 6e2ce16be0
2 changed files with 3 additions and 3 deletions

View file

@ -98,7 +98,6 @@ class Hooks implements ParserFirstCallInitHook {
return Utils::getErrorHtml( 'rss-empty', htmlspecialchars( $input ) );
}
// @phan-suppress-next-line SecurityCheck-XSS
return $rss->renderFeed( $parser, $frame );
}

View file

@ -391,6 +391,7 @@ class RSSParser {
*/
public function renderFeed( $parser, $frame ) {
$renderedFeed = '';
$wikitextFeed = '';
if ( isset( $this->itemTemplate ) && isset( $parser ) && isset( $frame ) ) {
$headcnt = 0;
@ -404,12 +405,12 @@ class RSSParser {
}
if ( $this->canDisplay( $item ) ) {
$renderedFeed .= $this->renderItem( $item, $parser ) . "\n";
$wikitextFeed .= $this->renderItem( $item, $parser ) . "\n";
$headcnt++;
}
}
$renderedFeed = $this->sandboxParse( $renderedFeed, $parser );
$renderedFeed = $this->sandboxParse( $wikitextFeed, $parser );
}