From 4cfeed615cc1e53846c6a6f0be94226158b3ec11 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 23 Mar 2007 01:45:24 +0000 Subject: [PATCH] Don't prepend protocol to relative links. fixes #4017 #4001 for trunk git-svn-id: http://svn.automattic.com/wordpress/trunk@5088 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/formatting.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index a36de22477..a0c13dbe66 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -1072,6 +1072,11 @@ function clean_url( $url, $protocols = null ) { $strip = array('%0d', '%0a'); $url = str_replace($strip, '', $url); $url = str_replace(';//', '://', $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 = (strpos($url, '://') === false && substr( $url, 0, 1 ) != '/' ) ? 'http://'.$url : $url; $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); if ( !is_array($protocols) )