make_clickable: When cleaning up accidental links within links, account for the tag being split by newlines.

props dd32.
fixes #19028.


git-svn-id: https://develop.svn.wordpress.org/trunk@26974 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2014-01-17 09:31:59 +00:00
parent 67d1c9fd6d
commit 5cb20092ce
2 changed files with 10 additions and 1 deletions

View File

@ -1742,7 +1742,7 @@ function make_clickable( $text ) {
}
// Cleanup of accidental links within links
$r = preg_replace( '#(<a( [^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r );
$r = preg_replace( '#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r );
return $r;
}

View File

@ -380,4 +380,13 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase {
$this->assertEquals( $urls_expected[$key], make_clickable( $url ) );
}
}
/**
* @ticket 19028
*/
function test_line_break_in_existing_clickable_link() {
$html = "<a
href='mailto:someone@example.com'>someone@example.com</a>";
$this->assertEquals( $html, make_clickable( $html ) );
}
}