Recognize urls that start with a question mark as relative urls that do not require a scheme to be prepended. fixes #18260

git-svn-id: http://svn.automattic.com/wordpress/trunk@18469 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2011-07-26 19:44:18 +00:00
parent c2d37a3d65
commit 55d7366c42
1 changed files with 3 additions and 3 deletions

View File

@ -2256,10 +2256,10 @@ function esc_url( $url, $protocols = null, $_context = 'display' ) {
$url = str_replace(';//', '://', $url);
/* If the URL doesn't appear to contain a scheme, we
* presume it needs http:// appended (unless a relative
* link starting with / or a php file).
* link starting with /, # or ? or a php file).
*/
if ( strpos($url, ':') === false &&
substr( $url, 0, 1 ) != '/' && substr( $url, 0, 1 ) != '#' && !preg_match('/^[a-z0-9-]+?\.php/i', $url) )
if ( strpos($url, ':') === false && ! in_array( $url[0], array( '/', '#', '?' ) ) &&
! preg_match('/^[a-z0-9-]+?\.php/i', $url) )
$url = 'http://' . $url;
// Replace ampersands and single quotes only when displaying.