r55974 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55973‎ | r55974 | r55975 >
Date:15:25, 7 September 2009
Author:simetrical
Status:ok (Comments)
Tags:
Comment:
Fix silly <table class=''>
Modified paths:
  • /trunk/phase3/includes/HTMLForm.php (modified) (history)
  • /trunk/phase3/includes/Html.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/HTMLForm.php
@@ -313,7 +313,8 @@
314314 $classes[] = 'mw-htmlform-nolabel';
315315 $classes = implode( ' ', $classes );
316316
317 - $tableHtml = "<table class='$classes'><tbody>\n$tableHtml\n</tbody></table>\n";
 317+ $tableHtml = Html::rawElement( 'table', array( 'class' => $classes ),
 318+ Html::rawElement( 'tbody', array(), "\n$tableHtml\n" ) ) . "\n";
318319
319320 return $subsectionHtml . "\n" . $tableHtml;
320321 }
Index: trunk/phase3/includes/Html.php
@@ -232,19 +232,24 @@
233233
234234 $element = strtolower( $element );
235235
236 - # Simple checks using $attribDefaults
237236 foreach ( $attribs as $attrib => $value ) {
238237 $lcattrib = strtolower( $attrib );
 238+ $value = strval( $value );
239239
 240+ # Simple checks using $attribDefaults
240241 if ( isset( $attribDefaults[$element][$lcattrib] ) &&
241 - $attribDefaults[$element][$lcattrib] === $value ) {
 242+ $attribDefaults[$element][$lcattrib] == $value ) {
242243 unset( $attribs[$attrib] );
243244 }
 245+
 246+ if ( $lcattrib == 'class' && $value == '' ) {
 247+ unset( $attribs[$attrib] );
 248+ }
244249 }
245250
246251 # More subtle checks
247252 if ( $element === 'link' && isset( $attribs['type'] )
248 - && $attribs['type'] === 'text/css' ) {
 253+ && strval( $attribs['type'] ) == 'text/css' ) {
249254 unset( $attribs['type'] );
250255 }
251256 if ( $element === 'select' && isset( $attribs['size'] ) ) {
@@ -252,12 +257,12 @@
253258 || ( isset( $attribs['multiple'] ) && $attribs['multiple'] !== false )
254259 ) {
255260 # A multi-select
256 - if ( $attribs['size'] === '4' ) {
 261+ if ( strval( $attribs['size'] ) == '4' ) {
257262 unset( $attribs['size'] );
258263 }
259264 } else {
260265 # Single select
261 - if ( $attribs['size'] === '1' ) {
 266+ if ( strval( $attribs['size'] ) == '1' ) {
262267 unset( $attribs['size'] );
263268 }
264269 }

Comments

#Comment by Brion VIBBER (talk | contribs)   19:33, 8 September 2009

We should think about building some unit tests for these generator funcs to make sure the validation and escaping rules are working right.

Status & tagging log