r24882 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24881‎ | r24882 | r24883 >
Date:17:06, 17 August 2007
Author:robchurch
Status:old
Tags:
Comment:
Make Xml::expandAttributes() a bit more robust against non-array arguments; people keep passing it things it doesn't like :(
Modified paths:
  • /trunk/phase3/includes/Xml.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Xml.php
@@ -41,15 +41,12 @@
4242 * @param $attribs Array of attributes for an XML element
4343 */
4444 private static function expandAttributes( $attribs ) {
45 - if( is_null( $attribs ) ) {
46 - return null;
47 - } else {
48 - $out = '';
49 - foreach( $attribs as $name => $val ) {
50 - $out .= ' ' . $name . '="' . Sanitizer::encodeAttribute( $val ) . '"';
51 - }
52 - return $out;
 45+ $out = '';
 46+ if( is_array( $attribs ) ) {
 47+ foreach( $attribs as $name => $val )
 48+ $out .= " {$name}=\"" . Sanitizer::encodeAttribute( $val ) . '"';
5349 }
 50+ return $out;
5451 }
5552
5653 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r24948aaand restore behavior from prior to r24882 on expected inputbrion13:46, 20 August 2007
r25016Merged revisions 24866-25015 via svnmerge from...david23:06, 21 August 2007

Status & tagging log