Make WordPress Core

Ticket #1170: 1170.diff

File 1170.diff, 1.3 KB (added by Nazgul, 17 years ago)
  • wp-includes/formatting.php

     
    439439                return $text;
    440440
    441441        $tagstack = array(); $stacksize = 0; $tagqueue = ''; $newtext = '';
     442        $single_tags = array('br', 'hr', 'img', 'input'); //Known single-entity/self-closing tags
     443        $nestable_tags = array('blockquote', 'div', 'span'); //Tags that can be immediately nested within themselves
    442444
    443445        # WP bug fix for comments - in case you REALLY meant to type '< !--'
    444446        $text = str_replace('< !--', '<    !--', $text);
     
    489491                        if((substr($regex[2],-1) == '/') || ($tag == '')) {
    490492                        }
    491493                        // ElseIf it's a known single-entity tag but it doesn't close itself, do so
    492                         elseif ($tag == 'br' || $tag == 'img' || $tag == 'hr' || $tag == 'input') {
     494                        elseif ( in_array($tag, $single_tags) ) {
    493495                                $regex[2] .= '/';
    494496                        } else {        // Push the tag onto the stack
    495497                                // If the top of the stack is the same as the tag we want to push, close previous tag
    496                                 if (($stacksize > 0) && ($tag != 'div') && ($tagstack[$stacksize - 1] == $tag)) {
     498                                if (($stacksize > 0) && !in_array($tag, $nestable_tags) && ($tagstack[$stacksize - 1] == $tag)) {
    497499                                        $tagqueue = '</' . array_pop ($tagstack) . '>';
    498500                                        $stacksize--;
    499501                                }