Index: wp-testcase/test_includes_formatting.php
===================================================================
--- wp-testcase/test_includes_formatting.php	(revision 666)
+++ wp-testcase/test_includes_formatting.php	(working copy)
@@ -217,6 +217,22 @@
 		}
 	}
 
+	function test_wrapped_in_angles() {
+		$before = array(
+			'URL wrapped in angle brackets <http://example.com/>',
+			'URL wrapped in angle brackets with padding < http://example.com/ >',
+			'mailto wrapped in angle brackets <foo@example.com>',
+		);
+		$expected = array(
+			'URL wrapped in angle brackets <<a href="http://example.com/" rel="nofollow">http://example.com/</a>>',
+			'URL wrapped in angle brackets with padding < <a href="http://example.com/" rel="nofollow">http://example.com/</a> >',
+			'mailto wrapped in angle brackets <foo@example.com>',
+		);
+		foreach ($before as $key => $url) {
+			$this->assertEquals($expected[$key], make_clickable($url));
+		}
+	}
+
 	function test_preceded_by_punctuation() {
 		$before = array(
 			'Comma then URL,http://example.com/',
@@ -225,7 +241,6 @@
 			'Colon then URL:http://example.com/',
 			'Exclamation mark then URL!http://example.com/',
 			'Question mark then URL?http://example.com/',
-			'URL wrapped in angle brackets <http://example.com/>',
 		);
 		$expected = array(
 			'Comma then URL,<a href="http://example.com/" rel="nofollow">http://example.com/</a>',
@@ -234,7 +249,6 @@
 			'Colon then URL:<a href="http://example.com/" rel="nofollow">http://example.com/</a>',
 			'Exclamation mark then URL!<a href="http://example.com/" rel="nofollow">http://example.com/</a>',
 			'Question mark then URL?<a href="http://example.com/" rel="nofollow">http://example.com/</a>',
-			'URL wrapped in angle brackets <<a href="http://example.com/" rel="nofollow">http://example.com/</a>>',
 		);
 		foreach ($before as $key => $url) {
 			$this->assertEquals($expected[$key], make_clickable($url));
@@ -249,6 +263,7 @@
 			"http://trunk.domain/testing#something
 			(<img src='http://trunk.domain/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley'>)",
 			"<span style='text-align:center; display: block;'><object width='425' height='350'><param name='movie' value='http://www.youtube.com/v/nd_BdvG43rE&rel=1&fs=1&showsearch=0&showinfo=1&iv_load_policy=1' /> <param name='allowfullscreen' value='true' /> <param name='wmode' value='opaque' /> <embed src='http://www.youtube.com/v/nd_BdvG43rE&rel=1&fs=1&showsearch=0&showinfo=1&iv_load_policy=1' type='application/x-shockwave-flash' allowfullscreen='true' width='425' height='350' wmode='opaque'></embed> </object></span>",
+			'<a href="http://example.com/example.gif" title="Image from http://example.com">Look at this image!</a>',
 		);
 		$urls_expected = array(
 			"<img src='http://trunk.domain/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley'>",
@@ -257,6 +272,7 @@
 			"<a href=\"http://trunk.domain/testing#something\" rel=\"nofollow\">http://trunk.domain/testing#something</a>
 			(<img src='http://trunk.domain/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley'>)",
 			"<span style='text-align:center; display: block;'><object width='425' height='350'><param name='movie' value='http://www.youtube.com/v/nd_BdvG43rE&rel=1&fs=1&showsearch=0&showinfo=1&iv_load_policy=1' /> <param name='allowfullscreen' value='true' /> <param name='wmode' value='opaque' /> <embed src='http://www.youtube.com/v/nd_BdvG43rE&rel=1&fs=1&showsearch=0&showinfo=1&iv_load_policy=1' type='application/x-shockwave-flash' allowfullscreen='true' width='425' height='350' wmode='opaque'></embed> </object></span>",
+			'<a href="http://example.com/example.gif" title="Image from http://example.com">Look at this image!</a>',
 		);
 		foreach ($urls_before as $key => $url) {
 			$this->assertEquals($urls_expected[$key], make_clickable($url));
@@ -277,6 +293,29 @@
 			$this->assertEquals( $urls_expected[$key], make_clickable( $url ) );
 		}
 	}
+
+	function test_no_links_within_links() {
+		$in = array(
+			'Some text with a link <a href="http://example.com">http://example.com</a>',
+			//'<a href="http://wordpress.org">This is already a link www.wordpress.org</a>', // fails in 3.3.1 too
+		);
+		foreach ( $in as $text ) {
+			$this->assertEquals( $text, make_clickable( $text ) );
+		}
+	}
+
+	/**
+	 * @ticket 16892
+	 */
+	function test_no_segfault() {
+		if ( version_compare( $GLOBALS['wp_version'], '3.1.1', '<' ) )
+			$this->markTestSkipped();
+
+		$in = str_repeat( 'http://example.com/2011/03/18/post-title/', 256 );
+		$out = make_clickable( $in );
+		if ( version_compare( $GLOBALS['wp_version'], '3.4-alpha', '>=' ) )
+			$this->assertEquals( $in, $out );
+	}
 }
 
 class TestJSEscape extends WPTestCase {
