Return ``True`` if the url is a safe redirection (i.e. it doesn't point to
    a different host and uses a safe scheme).
    Always returns ``False`` on an empty url.
502559
def is_safe_url(url, host=None):
    
    if url is not None:
        url = url.strip()
    if not url:
        return False
    # Chrome treats \ completely as /
    url = url.replace("\\", "/")
    # Chrome considers any URL with more than two slashes to be absolute, but
    # urlparse is not so flexible. Treat any url with three slashes as unsafe.
    if url.startswith("///"):
        return False
    url_info = urlparse(url)
    # Forbid URLs like http:///example.com - with a scheme, but without a
    # hostname.
    # In that URL, example.com is not the hostname but, a path component.
    # However, Chrome will still consider example.com to be the hostname,
    # so we must not allow this syntax.
    if not url_info.netloc and url_info.scheme:
        return False
    # Forbid URLs that start with control characters. Some browsers (like
    # Chrome) ignore quite a few control characters at the start of a
    # URL and might consider the URL as scheme relative.
    if unicodedata.category(url[0])[0] == "C":
        return False
    return (not url_info.netloc or url_info.netloc == host) and (
        not url_info.scheme or url_info.scheme in {"http", "https"}
    )
1064426
def is_broken_link(url):
    """"""
    try:
        request = urllib_request.Request(
            url, headers={'User-Agent': 'Mozilla/5.0'})
        urllib_request.urlopen(request).read()
        return False
    except urllib_request.URLError:
        return True
    except SocketError:
        return True
1124652
def is_same_host(self, url):
        
        # TODO: Add optional support for socket.gethostbyname checking.
        return (url.startswith('/') or
                get_host(url) == (self.scheme, self.host, self.port))
948886
def validate_url(cls, url):
        

        if url is None:
            return None

        url = url.strip()
        while url.endswith('/'):
            url = url[:-1]
        return url
453352
def is_valid_url(url):
    
    regex = re.compile(
            r'^(?:http|ftp)s?://' # http:// or https://
            r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' #domain...
            #r'localhost|' #localhost...
            r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
            r'(?::\d+)?' # optional port
            r'(?:/?|[/?]\S+)$', re.IGNORECASE)
    return bool(regex.match(url))
567995
def url_is(white_list):
    
    def func(url):
        prefixes = white_list.get('PREFIXES', ())
        for prefix in prefixes:
            if url.startswith(prefix):
                return True
        constants = white_list.get('CONSTANTS', ())
        for exact_url in constants:
            if url == exact_url:
                return True
        return False
    return func
1159751
public function isRedirect()
    {
        return in_array(
            $this->getStatusCode(),
            [
                StatusCode::HTTP_MOVED_PERMANENTLY,
                StatusCode::HTTP_FOUND,
                StatusCode::HTTP_SEE_OTHER,
                StatusCode::HTTP_TEMPORARY_REDIRECT,
                StatusCode::HTTP_PERMANENT_REDIRECT
            ]
        );
    }
152809
def redirect(self, url, status=None):
        
        self.status_code = 302 if status is None else status
        self.headers = Headers([('location', url)])
        self.message = ''
        self.end()
649893
def check_url(url):
        '''
        

        '''
        request = urllib2.Request(url)
        try:
            response = urlopen(request)
            return True, response.code
        except urllib2.HTTPError as e:
            return False, e.code
155683
public boolean isHttpRedirect() {
		if (isRevisitDigest() && (getDuplicatePayload() != null)) {
			return getDuplicatePayload().isHttpRedirect();
		}
		String httpCode = getHttpCode();
		return (httpCode.startsWith("3"));
	}
148819
def _is_valid_url(self, url):
        """"""
        try:
            r = requests.head(url, proxies=self.proxy_servers)
            value = r.status_code in [200]
        except Exception as error:
            logger.error(str(error))
            value = False

        return value
1270058
def is_active_feature(feature, redirect_to=None, redirect=None):
  
  def _is_active_feature(func):
    @wraps(func)
    def wrapped(*args, **kwargs):

      if not is_active(feature):
        url = redirect_to
        if redirect:
          url = url_for(redirect)

        if url:
          log.debug(u'Feature {feature} is off, redirecting to {url}'.format(feature=feature, url=url))
          return _redirect(url, code=302)
        else:
          log.debug(u'Feature {feature} is off, aborting request'.format(feature=feature))
          abort(404)

      return func(*args, **kwargs)
    return wrapped
  return _is_active_feature
1310219
private boolean isRedirectHostTheSameAsLocalHost(String exitPage, String logoutURLhost, String hostFullName, String shortName, String ipAddress) {
        String localHostIpAddress = "127.0.0.1";
        boolean acceptURL = false;
        if (logoutURLhost.equalsIgnoreCase("localhost") || logoutURLhost.equals(localHostIpAddress) ||
            (hostFullName != null && logoutURLhost.equalsIgnoreCase(hostFullName)) ||
            (shortName != null && logoutURLhost.equalsIgnoreCase(shortName)) ||
            (ipAddress != null && logoutURLhost.equals(ipAddress))) {

            acceptURL = true;
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "exitPage points to this host: all ok");
        }
        return acceptURL;
    }
832947
def url_is_from_any_domain(url, domains):
    """"""
    host = parse_url(url).netloc.lower()

    if host:
        return any(((host == d.lower()) or (host.endswith('.%s' % d.lower())) for d in domains))
    else:
        return False
709342
def get_success_url(self):
        """"""
        redirect_to = self.request.POST.get(
            self.redirect_field_name,
            self.request.GET.get(self.redirect_field_name, '')
        )
        url_is_safe = is_safe_url(
            url=redirect_to,
            # allowed_hosts=self.get_success_url_allowed_hosts(),
            # require_https=self.request.is_secure(),
        )
        if not url_is_safe:
            return resolve_url(settings.LOGIN_REDIRECT_URL)
        return redirect_to
1014717
def is_local_url(target):
    """"""
    ref_url = urlparse(cfg.get('CFG_SITE_SECURE_URL'))
    test_url = urlparse(urljoin(cfg.get('CFG_SITE_SECURE_URL'), target))
    return test_url.scheme in ('http', 'https') and \
        ref_url.netloc == test_url.netloc
1004614
def is_url(string, allowed_schemes=None):
    
    if not is_full_string(string):
        return False
    valid = bool(URL_RE.search(string))
    if allowed_schemes:
        return valid and any([string.startswith(s) for s in allowed_schemes])
    return valid