Fix relative link mangling in clean_url. fixes #4017 for 2.1

git-svn-id: http://svn.automattic.com/wordpress/branches/2.0@5097 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-03-23 23:33:19 +00:00
parent efd3bae515
commit bbd24106bd

View File

@ -1051,7 +1051,11 @@ function clean_url( $url, $protocols = null ) {
$strip = array('%0d', '%0a');
$url = str_replace($strip, '', $url);
$url = str_replace(';//', '://', $url);
$url = (strpos($url, '://') === false && substr( $url, 0, 1 ) != '/' ) ? 'http://'.$url : $url;
// Append http unless a relative link starting with / or a php file.
if ( strpos($url, '://') === false &&
substr( $url, 0, 1 ) != '/' && !preg_match('/^[a-z0-9]+?\.php/i', $url) )
$url = 'http://' . $url;
$url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url);
if ( !is_array($protocols) )
$protocols = array('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet');