Created
October 27, 2014 14:25
-
-
Save eugene-ilyin/358e3786a547321adf91 to your computer and use it in GitHub Desktop.
Drupal check that url is really external
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Check url for external property. | |
*/ | |
function module_url_is_external($path) { | |
global $base_url; | |
$url_host = parse_url($path); | |
if (empty($url_host['host']) && empty($url_host['scheme'])) { | |
return FALSE; | |
} else { | |
if ($url_host['scheme'] . '://' . $url_host['host'] === substr($base_url, 0, strlen($url_host['scheme'] . '://' . $url_host['host']))) { | |
return FALSE; | |
} | |
} | |
return TRUE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment