r80978 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80977‎ | r80978 | r80979 >
Date:18:33, 25 January 2011
Author:philip
Status:ok (Comments)
Tags:
Comment:
LanguageConverter::captionConvert(): remove HTML tags and escape HTML special chars to prevent disrupting the layout.
Modified paths:
  • /trunk/phase3/languages/LanguageConverter.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/LanguageConverter.php
@@ -308,14 +308,23 @@
309309 * @return String like ' alt="yyyy"' or ' title="yyyy"'
310310 */
311311 protected function captionConvert( $matches ) {
 312+ // TODO: cache the preferred variant in every autoConvert() process,
 313+ // this helps improve performance in a way.
312314 $toVariant = $this->getPreferredVariant();
313315 $title = $matches[1];
314 - $text = $matches[2];
 316+ $text = $matches[2];
 317+
315318 // we convert captions except URL
316319 if ( !strpos( $text, '://' ) ) {
317320 $text = $this->translate( $text, $toVariant );
318321 }
319 - return " $title=\"$text\"";
 322+
 323+ // remove HTML tags to prevent disrupting the layout
 324+ $text = preg_replace( '/<[^>]+>/', '', $text );
 325+ // escape HTML special chars to prevent disrupting the layout
 326+ $text = htmlspecialchars( $text );
 327+
 328+ return " {$title}=\"{$text}\"";
320329 }
321330
322331 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r810791.17: MFT r80507, r80634, r80770, r80961, r80978, r80985, r81042, r81060, r81...catrope01:15, 27 January 2011
r81653Fix whitespace from r80978tstarling22:11, 7 February 2011

Comments

#Comment by Catrope (talk | contribs)   22:29, 25 January 2011
 	protected function captionConvert( $matches ) {
+	  // TODO: cache the preferred variant in every autoConvert() process,
+	  // this helps improve performance in a way.

Uses spaces for indentation.

Status & tagging log