Don't attempt to make links inside attributes clickable. Props duck_ azaozz. fixes #20418
git-svn-id: http://svn.automattic.com/wordpress/trunk@20443 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2dd485a823
commit
be5802b0f1
|
@ -1468,25 +1468,30 @@ function _make_email_clickable_cb($matches) {
|
||||||
*
|
*
|
||||||
* @since 0.71
|
* @since 0.71
|
||||||
*
|
*
|
||||||
* @param string $ret Content to convert URIs.
|
* @param string $text Content to convert URIs.
|
||||||
* @return string Content with converted URIs.
|
* @return string Content with converted URIs.
|
||||||
*/
|
*/
|
||||||
function make_clickable( $ret ) {
|
function make_clickable( $text ) {
|
||||||
// Long strings might contain expensive edge cases ...
|
|
||||||
if ( 10000 < strlen( $ret ) ) {
|
|
||||||
$r = '';
|
$r = '';
|
||||||
|
$textarr = preg_split( '/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // split out HTML tags
|
||||||
|
foreach ( $textarr as $piece ) {
|
||||||
|
if ( empty( $piece ) || ( $piece[0] == '<' && ! preg_match('|^<\s*[\w]{1,20}+://|', $piece) ) ) {
|
||||||
|
$r .= $piece;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Long strings might contain expensive edge cases ...
|
||||||
|
if ( 10000 < strlen( $piece ) ) {
|
||||||
// ... break it up
|
// ... break it up
|
||||||
foreach ( _split_str_by_whitespace( $ret, 2100 ) as $chunk ) { // 2100: Extra room for scheme and leading and trailing paretheses
|
foreach ( _split_str_by_whitespace( $piece, 2100 ) as $chunk ) { // 2100: Extra room for scheme and leading and trailing paretheses
|
||||||
if ( 2101 < strlen( $chunk ) ) {
|
if ( 2101 < strlen( $chunk ) ) {
|
||||||
$r .= $chunk; // Too big, no whitespace: bail.
|
$r .= $chunk; // Too big, no whitespace: bail.
|
||||||
} else {
|
} else {
|
||||||
$r .= make_clickable( $chunk );
|
$r .= make_clickable( $chunk );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $r;
|
} else {
|
||||||
}
|
$ret = " $piece "; // Pad with whitespace to simplify the regexes
|
||||||
|
|
||||||
$ret = " $ret "; // Pad with whitespace to simplify the regexes
|
|
||||||
|
|
||||||
$url_clickable = '~
|
$url_clickable = '~
|
||||||
([\\s(<.,;:!?]) # 1: Leading whitespace, or punctuation
|
([\\s(<.,;:!?]) # 1: Leading whitespace, or punctuation
|
||||||
|
@ -1508,9 +1513,14 @@ function make_clickable( $ret ) {
|
||||||
$ret = preg_replace_callback( '#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret );
|
$ret = preg_replace_callback( '#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret );
|
||||||
$ret = preg_replace_callback( '#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret );
|
$ret = preg_replace_callback( '#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret );
|
||||||
|
|
||||||
|
$ret = substr( $ret, 1, -1 ); // Remove our whitespace padding.
|
||||||
|
$r .= $ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Cleanup of accidental links within links
|
// Cleanup of accidental links within links
|
||||||
$ret = preg_replace("#(<a( [^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i", "$1$3</a>", $ret);
|
$r = preg_replace( '#(<a( [^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r );
|
||||||
return substr( $ret, 1, -1 ); // Remove our whitespace padding.
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue