r56407 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56406‎ | r56407 | r56408 >
Date:05:29, 16 September 2009
Author:mrzman
Status:ok
Tags:
Comment:
(bug 20655) If $wgHtml5 is false, run attribute values through Sanitizer::encodeAttribute()
Modified paths:
  • /trunk/phase3/includes/Html.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Html.php
@@ -335,13 +335,17 @@
336336 # and we don't need <> escaped here, we may as well not call
337337 # htmlspecialchars(). FIXME: verify that we actually need to
338338 # escape \n\r\t here, and explain why, exactly.
339 - $ret .= " $key=$quote" . strtr( $value, array(
340 - '&' => '&amp;',
341 - '"' => '&quot;',
342 - "\n" => '&#10;',
343 - "\r" => '&#13;',
344 - "\t" => '&#9;'
345 - ) ) . $quote;
 339+ if ( $wgHtml5 ) {
 340+ $ret .= " $key=$quote" . strtr( $value, array(
 341+ '&' => '&amp;',
 342+ '"' => '&quot;',
 343+ "\n" => '&#10;',
 344+ "\r" => '&#13;',
 345+ "\t" => '&#9;'
 346+ ) ) . $quote;
 347+ } else {
 348+ $ret .= " $key=$quote" . Sanitizer::encodeAttribute( $value ) . $quote;
 349+ }
346350 }
347351 }
348352 return $ret;

Follow-up revisions

RevisionCommit summaryAuthorDate
r57182Escape '<' in attribute values for well-formed XML...simetrical01:30, 1 October 2009

Status & tagging log