Index: wp-includes/formatting.php
===================================================================
--- wp-includes/formatting.php	(revision 23001)
+++ wp-includes/formatting.php	(working copy)
@@ -1181,12 +1181,39 @@
 	// WP bug fix for LOVE <3 (and other situations with '<' before a number)
 	$text = preg_replace('#<([0-9]{1})#', '&lt;$1', $text);
 
-	while ( preg_match("/<(\/?[\w:]*)\s*([^>]*)>/", $text, $regex) ) {
+	$tag_regex = "/<(\/?[\w:]*)\s*([^>]*)>/";
+
+	while ( preg_match($tag_regex, $text, $regex) ) {
 		$newtext .= $tagqueue;
 
 		$i = strpos($text, $regex[0]);
 		$l = strlen($regex[0]);
+		$newtext .= substr($text, 0, $i);
+		$text = substr($text, $i + $l);
 
+		// WP bug fix for dangling lone <
+		if ( strlen( $regex[1] ) === 0 ) {
+		    // Trim off up to and including lone <, encode it
+		    $temp_text = $regex[0];
+		    $lone_pos = strpos( $temp_text, '<' );
+		    $lone_text = substr( $temp_text, 0, $lone_pos + 1 );
+		    $temp_text = substr( $temp_text, $lone_pos + 1 );
+		    $lone_text = str_replace( '<', '&lt;', $lone_text );
+		    $newtext .= $lone_text;
+
+		    // Rerun the match against the remaining text
+		    if ( preg_match( $tag_regex, $temp_text, $regex )) {
+			$i = strpos( $temp_text, $regex[0] );
+			$l = strlen( $regex[0] );
+			$newtext .= substr( $temp_text, 0, $i );
+		    }
+		    else {
+			// Shouldn't happen, since the match should always
+			// have started out similar to '< <foo>'.
+			continue;
+		    }
+		}
+
 		// clear the shifter
 		$tagqueue = '';
 		// Pop or Push
@@ -1258,15 +1285,14 @@
 				$tag = '';
 			}
 		}
-		$newtext .= substr($text, 0, $i) . $tag;
-		$text = substr($text, $i + $l);
+		$newtext .= $tag; 
 	}
 
 	// Clear Tag Queue
 	$newtext .= $tagqueue;
 
 	// Add Remaining text
-	$newtext .= $text;
+	$newtext .= str_replace( '<', '&lt;', $text );
 
 	// Empty Stack
 	while( $x = array_pop($tagstack) )
