Merge "SpecialUserlogin: Error out when attempting to create a username with a '#'"
[lhc/web/wiklou.git] / includes / HtmlFormatter.php
index 96ffe9e..987a683 100644 (file)
@@ -136,9 +136,15 @@ class HtmlFormatter {
                wfProfileIn( __METHOD__ );
                $removals = $this->parseItemsToRemove();
 
-               if ( !$removals ) {
+               // Bail out early if nothing to do
+               if ( array_reduce( $removals,
+                       function( $carry, $item ) {
+                               return $carry && !$item;
+                       },
+                       true
+               ) ) {
                        wfProfileOut( __METHOD__ );
-                       return;
+                       return array();
                }
 
                $doc = $this->getDoc();
@@ -287,11 +293,12 @@ class HtmlFormatter {
                                // XML code paths if possible and fix there.
                                $html = str_replace( '
', '', $html );
                        }
-                       $html = preg_replace( '/<!--.*?-->|^.*?<body>|<\/body>.*$/s', '', $html );
                        wfProfileOut( __METHOD__ . '-fixes' );
                } else {
                        $html = $this->html;
                }
+               // Remove stuff added by wrapHTML()
+               $html = preg_replace( '/<!--.*?-->|^.*?<body>|<\/body>.*$/s', '', $html );
                $html = $this->onHtmlReady( $html );
 
                wfProfileIn( __METHOD__ . '-flatten' );