Ticket #1170: bug1170_functions-formatting2.diff

File bug1170_functions-formatting2.diff, 1.3 KB (added by anonymousbugger, 7 years ago)
  • wp-includes/functions-formatting.php

     
    392392        } 
    393393 
    394394        $tagstack = array(); $stacksize = 0; $tagqueue = ''; $newtext = ''; 
     395        $single_tags = array('br', 'hr', 'img', 'input'); //Known single-entity/self-closing tags 
     396        $nestable_tags = array('blockquote', 'div', 'span'); //Tags that can be immediately nested within themselves 
    395397 
    396398        # WP bug fix for comments - in case you REALLY meant to type '< !--' 
    397399        $text = str_replace('< !--', '<    !--', $text); 
     
    442444                        if((substr($regex[2],-1) == '/') || ($tag == '')) { 
    443445                        } 
    444446                        // ElseIf it's a known single-entity tag but it doesn't close itself, do so 
    445                         elseif ($tag == 'br' || $tag == 'img' || $tag == 'hr' || $tag == 'input') { 
     447                        elseif ( in_array($tag, $single_tags) ) { 
    446448                                $regex[2] .= '/'; 
    447449                        } else {        // Push the tag onto the stack 
    448450                                // If the top of the stack is the same as the tag we want to push, close previous tag 
    449                                 if (($stacksize > 0) && ($tag != 'div') && ($tagstack[$stacksize - 1] == $tag)) { 
     451                                if (($stacksize > 0) && !in_array($tag, $nestable_tags) && ($tagstack[$stacksize - 1] == $tag)) { 
    450452                                        $tagqueue = '</' . array_pop ($tagstack) . '>'; 
    451453                                        $stacksize--; 
    452454                                }