mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-12 13:44:21 +01:00
Fix nestable HTML, including <blockquote>'s. Props anonymousbugger (!) and Nazgul. fixes #1170
git-svn-id: http://svn.automattic.com/wordpress/trunk@5623 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9e8bfa7f7b
commit
b8c26df7e0
@ -439,6 +439,8 @@ function balanceTags($text, $force = false) {
|
|||||||
return $text;
|
return $text;
|
||||||
|
|
||||||
$tagstack = array(); $stacksize = 0; $tagqueue = ''; $newtext = '';
|
$tagstack = array(); $stacksize = 0; $tagqueue = ''; $newtext = '';
|
||||||
|
$single_tags = array('br', 'hr', 'img', 'input'); //Known single-entity/self-closing tags
|
||||||
|
$nestable_tags = array('blockquote', 'div', 'span'); //Tags that can be immediately nested within themselves
|
||||||
|
|
||||||
# WP bug fix for comments - in case you REALLY meant to type '< !--'
|
# WP bug fix for comments - in case you REALLY meant to type '< !--'
|
||||||
$text = str_replace('< !--', '< !--', $text);
|
$text = str_replace('< !--', '< !--', $text);
|
||||||
@ -489,11 +491,11 @@ function balanceTags($text, $force = false) {
|
|||||||
if((substr($regex[2],-1) == '/') || ($tag == '')) {
|
if((substr($regex[2],-1) == '/') || ($tag == '')) {
|
||||||
}
|
}
|
||||||
// ElseIf it's a known single-entity tag but it doesn't close itself, do so
|
// ElseIf it's a known single-entity tag but it doesn't close itself, do so
|
||||||
elseif ($tag == 'br' || $tag == 'img' || $tag == 'hr' || $tag == 'input') {
|
elseif ( in_array($tag, $single_tags) ) {
|
||||||
$regex[2] .= '/';
|
$regex[2] .= '/';
|
||||||
} else { // Push the tag onto the stack
|
} else { // Push the tag onto the stack
|
||||||
// If the top of the stack is the same as the tag we want to push, close previous tag
|
// If the top of the stack is the same as the tag we want to push, close previous tag
|
||||||
if (($stacksize > 0) && ($tag != 'div') && ($tagstack[$stacksize - 1] == $tag)) {
|
if (($stacksize > 0) && !in_array($tag, $nestable_tags) && ($tagstack[$stacksize - 1] == $tag)) {
|
||||||
$tagqueue = '</' . array_pop ($tagstack) . '>';
|
$tagqueue = '</' . array_pop ($tagstack) . '>';
|
||||||
$stacksize--;
|
$stacksize--;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user