Index: wp-includes/formatting.php
===================================================================
--- wp-includes/formatting.php	(revision 12345)
+++ wp-includes/formatting.php	(working copy)
@@ -1393,7 +1393,10 @@
 function wp_rel_nofollow_callback( $matches ) {
 	$text = $matches[1];
 	$text = str_replace(array(' rel="nofollow"', " rel='nofollow'"), '', $text);
-	return "<a $text rel=\"nofollow\">";
+	if (preg_match('%href=["\']('.get_option('siteurl').')?(\.){0,2}(/|#|["\'])%i', $text))
+		return "<a $text>";
+	else
+		return "<a $text rel=\"nofollow\">";
 }
 
 
