Ticket #1597: 1597.3.diff
File 1597.3.diff, 2.4 KB (added by , 12 years ago) |
---|
-
wp-includes/formatting.php
1155 1155 $stacksize = 0; 1156 1156 $tagqueue = ''; 1157 1157 $newtext = ''; 1158 $single_tags = array( ' br', 'hr', 'img', 'input' ); // Known single-entity/self-closing tags1158 $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 1159 1159 $nestable_tags = array( 'blockquote', 'div', 'object', 'q', 'span' ); // Tags that can be immediately nested within themselves 1160 1160 1161 1161 // WP bug fix for comments - in case you REALLY meant to type '< !--' … … 1203 1203 1204 1204 // Tag Cleaning 1205 1205 1206 // If self-closing or '', don't do anything.1207 if ( substr($regex[2],-1) == '/' || $tag == '') {1206 // If it's an empty tag "< >", do nothing 1207 if ( '' == $tag ) { 1208 1208 // do nothing 1209 1209 } 1210 // ElseIf it presents itself as a self-closing tag... 1211 elseif ( substr( $regex[2], -1 ) == '/' ) { 1212 // ...but it isn't a known single-entity self-closing tag, then don't let it be treated as such and 1213 // immediately close it with a closing tag (the tag will encapsulate no text as a result) 1214 if ( ! in_array( $tag, $single_tags ) ) 1215 $regex[2] = trim( substr( $regex[2], 0, -1 ) ) . "></$tag"; 1216 } 1210 1217 // ElseIf it's a known single-entity tag but it doesn't close itself, do so 1211 1218 elseif ( in_array($tag, $single_tags) ) { 1212 1219 $regex[2] .= '/'; 1213 } else { // Push the tag onto the stack 1220 } 1221 // Else it's not a single-entity tag 1222 else { 1214 1223 // If the top of the stack is the same as the tag we want to push, close previous tag 1215 1224 if ( $stacksize > 0 && !in_array($tag, $nestable_tags) && $tagstack[$stacksize - 1] == $tag ) { 1216 $tagqueue = '</' . array_pop ($tagstack) . '>';1225 $tagqueue = '</' . array_pop( $tagstack ) . '>'; 1217 1226 $stacksize--; 1218 1227 } 1219 $stacksize = array_push ($tagstack, $tag);1228 $stacksize = array_push( $tagstack, $tag ); 1220 1229 } 1221 1230 1222 1231 // Attributes 1223 1232 $attributes = $regex[2]; 1224 if( ! empty($attributes))1225 $attributes = ' ' .$attributes;1233 if( ! empty( $attributes ) && $attributes[0] != '>' ) 1234 $attributes = ' ' . $attributes; 1226 1235 1227 1236 $tag = '<' . $tag . $attributes . '>'; 1228 1237 //If already queuing a close tag, then put this tag on, too