7 common.inc | url_is_external($path) |
Return TRUE if a path is external to Drupal (e.g. http://example.com).
If a path cannot be assessed by Drupal's menu handler, then we must treat it as potentially insecure.
Parameters
$path: The internal path or external URL being linked to, such as "node/34" or "http://example.com/foo".
Return value
Boolean TRUE or FALSE, where TRUE indicates an external path.
7 calls to url_is_external()
File
- drupal/
includes/ common.inc, line 2197 - Common functions that many Drupal modules will need to reference.
Code
function url_is_external($path) {
$colonpos = strpos($path, ':');
// Only call the slow drupal_strip_dangerous_protocols() if $path contains a
// ':' before any / ? or #.
return $colonpos !== FALSE && !preg_match('![/?#]!', substr($path, 0, $colonpos)) && drupal_strip_dangerous_protocols($path) == $path;
}