Changeset 5623

Show
Ignore:
Timestamp:
06/01/07 02:33:03 (1 year ago)
Author:
rob1n
Message:

Fix nestable HTML, including <blockquote>'s. Props anonymousbugger (!) and Nazgul. fixes #1170

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/formatting.php

    r5541 r5623  
    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 '< !--' 
     
    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--;