r110263 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110262‎ | r110263 | r110264 >
Date:23:50, 29 January 2012
Author:grafzahl
Status:deferred
Tags:
Comment:
Fixes bugs reported by Talin Salway <yenthefirst@gmail.com>:

* Use htmlspecialchars() instead of strip_tags() in order to preserve user input.
* Likewise, use htmlspecialchars() on message parameters in which HTML entities might accidentally be transformed.
* Protect parameter in score-invalidlang message with <nowiki> tags so that the error message is properly displayed in all cases.
Modified paths:
  • /trunk/extensions/Score/Score.body.php (modified) (history)
  • /trunk/extensions/Score/Score.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Score/Score.i18n.php
@@ -36,7 +36,7 @@
3737 $1',
3838 'score-desc' => 'Adds a tag for rendering musical scores with LilyPond',
3939 'score-getcwderr' => 'Unable to obtain current working directory',
40 - 'score-invalidlang' => 'Invalid score language lang="$1". Currently recognised languages are lang="lilypond" (the default) and lang="ABC".',
 40+ 'score-invalidlang' => 'Invalid score language lang="<nowiki>$1</nowiki>". Currently recognised languages are lang="lilypond" (the default) and lang="ABC".',
4141 'score-invalidoggoverride' => 'The file you specified with override_ogg is invalid. Please specify the file name only, omit <nowiki>[[…]]</nowiki> and the "{{ns:file}}:" prefix.',
4242 'score-noabcinput' => 'ABC source file $1 could not be created.',
4343 'score-noimages' => 'No score images were generated. Please check your score code.',
Index: trunk/extensions/Score/Score.body.php
@@ -127,7 +127,7 @@
128128 $message->rawParams(
129129 Html::rawElement( 'pre',
130130 array(),
131 - strip_tags( $output )
 131+ htmlspecialchars( $output )
132132 )
133133 )
134134 );
@@ -209,7 +209,7 @@
210210 $options['lang'] = 'lilypond';
211211 }
212212 if ( !in_array( $options['lang'], self::$supportedLangs ) ) {
213 - throw new ScoreException( wfMessage( 'score-invalidlang', $options['lang'] ) );
 213+ throw new ScoreException( wfMessage( 'score-invalidlang', htmlspecialchars( $options['lang'] ) ) );
214214 }
215215
216216 /* image file path and URL prefixes */
@@ -376,14 +376,14 @@
377377 );
378378 $link .= $oad->toHtml( array( 'alt' => $code ) );
379379 } catch ( Exception $e ) {
380 - throw new ScoreException( wfMessage( 'score-novorbislink', $e->getMessage() ), 0, $e );
 380+ throw new ScoreException( wfMessage( 'score-novorbislink', htmlspecialchars( $e->getMessage() ) ), 0, $e );
381381 }
382382 }
383383 if ( $options['override_ogg'] !== false ) {
384384 try {
385385 $link .= $parser->recursiveTagParse( "[[File:{$options['ogg_name']}]]" );
386386 } catch ( Exception $e ) {
387 - throw new ScoreException( wfMessage( 'score-novorbislink', $e->getMessage() ), 0, $e );
 387+ throw new ScoreException( wfMessage( 'score-novorbislink', htmlspecialchars( $e->getMessage() ) ), 0, $e );
388388 }
389389 }
390390 } catch ( Exception $e ) {

Status & tagging log