Ticket #1597: 1597.2.diff
| File 1597.2.diff, 2.4 KB (added by , 14 years ago) |
|---|
-
wp-includes/formatting.php
1093 1093 $stacksize = 0; 1094 1094 $tagqueue = ''; 1095 1095 $newtext = ''; 1096 $single_tags = array( 'br', 'hr', 'img', 'input'); // Known single-entity/self-closing tags1096 $single_tags = array('area', 'base', 'basefont', 'br', 'col', 'command', 'embed', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param', 'source'); // Known single-entity/self-closing tags 1097 1097 $nestable_tags = array( 'blockquote', 'div', 'span', 'q' ); // Tags that can be immediately nested within themselves 1098 1098 1099 1099 // WP bug fix for comments - in case you REALLY meant to type '< !--' … … 1141 1141 1142 1142 // Tag Cleaning 1143 1143 1144 // If self-closing or '', don't do anything.1145 if ( substr($regex[2],-1) == '/' || $tag == '') {1144 // If it's an empty tag "< >", do nothing 1145 if ( '' == $tag ) { 1146 1146 // do nothing 1147 1147 } 1148 // ElseIf it presents itself as a self-closing tag... 1149 elseif ( substr( $regex[2], -1 ) == '/' ) { 1150 // ...but it isn't a known single-entity self-closing tag, then don't let it be treated as such and 1151 // immediately close it with a closing tag (the tag will encapsulate no text as a result) 1152 if ( ! in_array( $tag, $single_tags ) ) 1153 $regex[2] = trim( substr( $regex[2], 0, -1 ) ) . "></$tag"; 1154 } 1148 1155 // ElseIf it's a known single-entity tag but it doesn't close itself, do so 1149 1156 elseif ( in_array($tag, $single_tags) ) { 1150 1157 $regex[2] .= '/'; 1151 } else { // Push the tag onto the stack 1158 } 1159 // Else it's not a single-entity tag 1160 else { 1152 1161 // If the top of the stack is the same as the tag we want to push, close previous tag 1153 1162 if ( $stacksize > 0 && !in_array($tag, $nestable_tags) && $tagstack[$stacksize - 1] == $tag ) { 1154 $tagqueue = '</' . array_pop ($tagstack) . '>';1163 $tagqueue = '</' . array_pop( $tagstack ) . '>'; 1155 1164 $stacksize--; 1156 1165 } 1157 $stacksize = array_push ($tagstack, $tag);1166 $stacksize = array_push( $tagstack, $tag ); 1158 1167 } 1159 1168 1160 1169 // Attributes 1161 1170 $attributes = $regex[2]; 1162 if( ! empty($attributes))1163 $attributes = ' ' .$attributes;1171 if( ! empty( $attributes ) && $attributes[0] != '>' ) 1172 $attributes = ' ' . $attributes; 1164 1173 1165 1174 $tag = '<' . $tag . $attributes . '>'; 1166 1175 //If already queuing a close tag, then put this tag on, too