Followup r94465 and r94465; Add phpunit tests for Sanitizer::fixDeprecatedAttributes...
[lhc/web/wiklou.git] / includes / Sanitizer.php
index 83cd5fd..8272ea4 100644 (file)
@@ -641,6 +641,14 @@ class Sanitizer {
                        'width' => array( 'width', array_merge( array( 'hr', 'pre' ), $table, $cells, $colls ) ),
                );
                
+               // Ensure that any upper case or mixed case attributes are converted to lowercase
+               foreach ( $attribs as $attribute => $value ) {
+                       if ( $attribute !== strtolower( $attribute ) && array_key_exists( strtolower( $attribute ), $presentationalAttribs ) ) {
+                               $attribs[strtolower( $attribute )] = $value;
+                               unset( $attribs[$attribute] );
+                       }
+               }
+               
                $style = "";
                foreach ( $presentationalAttribs as $attribute => $info ) {
                        list( $property, $elements ) = $info;
@@ -662,6 +670,11 @@ class Sanitizer {
                                $value = 'nowrap';
                        }
                        
+                       // clear="all" is clear: both; in css
+                       if ( $attribute === 'clear' && strtolower( $value ) === 'all' ) {
+                               $value = 'both';
+                       }
+                       
                        // Size based properties should have px applied to them if they have no unit
                        if ( in_array( $attribute, array( 'height', 'width', 'size' ) ) ) {
                                if ( preg_match( '/^[\d.]+$/', $value ) ) {