Ticket #22625: balanceTags-23001.patch
| File balanceTags-23001.patch, 1.9 KB (added by , 13 years ago) |
|---|
-
wp-includes/formatting.php
1181 1181 // WP bug fix for LOVE <3 (and other situations with '<' before a number) 1182 1182 $text = preg_replace('#<([0-9]{1})#', '<$1', $text); 1183 1183 1184 while ( preg_match("/<(\/?[\w:]*)\s*([^>]*)>/", $text, $regex) ) { 1184 $tag_regex = "/<(\/?[\w:]*)\s*([^>]*)>/"; 1185 1186 while ( preg_match($tag_regex, $text, $regex) ) { 1185 1187 $newtext .= $tagqueue; 1186 1188 1187 1189 $i = strpos($text, $regex[0]); 1188 1190 $l = strlen($regex[0]); 1191 $newtext .= substr($text, 0, $i); 1192 $text = substr($text, $i + $l); 1189 1193 1194 // WP bug fix for dangling lone < 1195 if ( strlen( $regex[1] ) === 0 ) { 1196 // Trim off up to and including lone <, encode it 1197 $temp_text = $regex[0]; 1198 $lone_pos = strpos( $temp_text, '<' ); 1199 $lone_text = substr( $temp_text, 0, $lone_pos + 1 ); 1200 $temp_text = substr( $temp_text, $lone_pos + 1 ); 1201 $lone_text = str_replace( '<', '<', $lone_text ); 1202 $newtext .= $lone_text; 1203 1204 // Rerun the match against the remaining text 1205 if ( preg_match( $tag_regex, $temp_text, $regex )) { 1206 $i = strpos( $temp_text, $regex[0] ); 1207 $l = strlen( $regex[0] ); 1208 $newtext .= substr( $temp_text, 0, $i ); 1209 } 1210 else { 1211 // Shouldn't happen, since the match should always 1212 // have started out similar to '< <foo>'. 1213 continue; 1214 } 1215 } 1216 1190 1217 // clear the shifter 1191 1218 $tagqueue = ''; 1192 1219 // Pop or Push … … 1258 1285 $tag = ''; 1259 1286 } 1260 1287 } 1261 $newtext .= substr($text, 0, $i) . $tag; 1262 $text = substr($text, $i + $l); 1288 $newtext .= $tag; 1263 1289 } 1264 1290 1265 1291 // Clear Tag Queue 1266 1292 $newtext .= $tagqueue; 1267 1293 1268 1294 // Add Remaining text 1269 $newtext .= $text;1295 $newtext .= str_replace( '<', '<', $text ); 1270 1296 1271 1297 // Empty Stack 1272 1298 while( $x = array_pop($tagstack) )