Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save eugene-ilyin/358e3786a547321adf91 to your computer and use it in GitHub Desktop.

Select an option

Save eugene-ilyin/358e3786a547321adf91 to your computer and use it in GitHub Desktop.

Revisions

  1. eugene-ilyin created this gist Oct 27, 2014.
    15 changes: 15 additions & 0 deletions drupal_check_that_url_is_really_external.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    /**
    * 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;
    }