make ORMRow compatible with load balancer, replace usage of wfGetDB( DB_MASTER )
[lhc/web/wiklou.git] / includes / Sanitizer.php
index 224b2d1..5aa0545 100644 (file)
@@ -387,9 +387,9 @@ class Sanitizer {
                        $htmlsingleonly = array( # Elements that cannot have close tags
                                'br', 'hr'
                        );
-                       $htmlnest = array( # Tags that can be nested--??
+                       $htmlnest = array( # Tags that can be nested directly or indirectly
                                'table', 'tr', 'td', 'th', 'div', 'blockquote', 'ol', 'ul',
-                               'dl', 'font', 'big', 'small', 'sub', 'sup', 'span'
+                               'li', 'dl', 'dt', 'dd', 'font', 'big', 'small', 'sub', 'sup', 'span'
                        );
                        $tabletags = array( # Can only appear inside table, we will close them
                                'td', 'th', 'tr',
@@ -510,6 +510,10 @@ class Sanitizer {
                                                } elseif ( isset( $htmlsingle[$t] ) ) {
                                                        # Hack to not close $htmlsingle tags
                                                        $brace = null;
+                                                       # Still need to push this optionally-closed tag to
+                                                       # the tag stack so that we can match end tags
+                                                       # instead of marking them as bad.
+                                                       array_push( $tagstack, $t );
                                                } elseif ( isset( $tabletags[$t] )
                                                && in_array( $t, $tagstack ) ) {
                                                        // New table tag but forgot to close the previous one
@@ -912,7 +916,7 @@ class Sanitizer {
                // Reject problematic keywords and control characters
                if ( preg_match( '/[\000-\010\016-\037\177]/', $value ) ) {
                        return '/* invalid control char */';
-               } elseif ( preg_match( '! expression | filter\s*: | accelerator\s*: | url\s*\( !ix', $value ) ) {
+               } elseif ( preg_match( '! expression | filter\s*: | accelerator\s*: | url\s*\( | image\s*\( | image-set\s*\( !ix', $value ) ) {
                        return '/* insecure input */';
                }
                return $value;
@@ -1183,6 +1187,7 @@ class Sanitizer {
         * attribs regex matches.
         *
         * @param $set Array
+        * @throws MWException
         * @return String
         */
        private static function getTagAttributeCallback( $set ) {