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: https://develop.svn.wordpress.org/trunk@18469 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2011-07-26 19:44:18 +00:00
parent 5d649a9235
commit 4a1c73746f

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.