def prevent_open_redirect(url):
    # Prevent an attacker from adding an arbitrary url after the
    # _next variable in the request.
    host = current.request.env.http_host
    print(host)
    if not url:
        return None
    if REGEX_OPEN_REDIRECT.match(url):
        parts = url.split('/')
        if len(parts) > 2 and parts[2] == host:
            return url
        return None
    return url
A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.