def is_safe_url ( url , host = None ) : if not url : return False netloc = urlparse . urlparse ( url ) [ 1 ] return not netloc or netloc == host
python url safety checker
Return True if the url is a safe redirection .
def is_safe_url(url, host=None):
    """Return ``True`` if the url is a safe redirection.

    The safe redirection means that it doesn't point to a different host.
    Always returns ``False`` on an empty url.
    """
    if not url:
        return False
    netloc = urlparse.urlparse(url)[1]
    return not netloc or netloc == host