You are here

function menu_path_is_external in Drupal 6

Returns TRUE if a path is external (e.g. http://example.com).

May be used early in bootstrap.

8 calls to menu_path_is_external()
drupal_access_denied in includes/common.inc
Generates a 403 error if the request is not allowed.
drupal_goto in includes/common.inc
Send the user to a different Drupal page.
drupal_not_found in includes/common.inc
Generates a 404 error if the request can not be handled.
menu_edit_item_validate in modules/menu/menu.admin.inc
Validate form values for a menu link being added or edited.
menu_link_save in includes/menu.inc
Save a menu link.

... See full list

File

includes/bootstrap.inc, line 1541
Functions that need to be loaded on every Drupal request.

Code

function menu_path_is_external($path) {

  // Avoid calling filter_xss_bad_protocol() if there is any slash (/),
  // hash (#) or question_mark (?) before the colon (:) occurrence - if any - as
  // this would clearly mean it is not a URL. If the path starts with 2 slashes
  // then it is always considered an external URL without an explicit protocol
  // part. Leading control characters may be ignored or mishandled by browsers,
  // so assume such a path may lead to an external location. The range matches
  // all UTF-8 control characters, class Cc.
  $colonpos = strpos($path, ':');

  // Some browsers treat \ as / so normalize to forward slashes.
  $path = str_replace('\\', '/', $path);
  return strpos($path, '//') === 0 || preg_match('/^[\\x00-\\x1F\\x7F-\\x9F]/u', $path) !== 0 || $colonpos !== FALSE && !preg_match('![/?#]!', substr($path, 0, $colonpos)) && filter_xss_bad_protocol($path, FALSE) == check_plain($path);
}