def sanitise_redirect_url(redirect_to):
 is_valid = True
 if ((not redirect_to) or (' ' in redirect_to)):
  is_valid = False
 elif ('//' in redirect_to):
  allowed_domains = getattr(settings, 'ALLOWED_EXTERNAL_OPENID_REDIRECT_DOMAINS', [])
  (s, netloc, p, q, f) = urlsplit(redirect_to)
  if netloc:
   if (netloc.find(':') != (-1)):
    (netloc, _) = netloc.split(':', 1)
   if (netloc not in allowed_domains):
    is_valid = False
 if (not is_valid):
  redirect_to = settings.LOGIN_REDIRECT_URL
 return redirect_to

def sanitise_redirect_url ( redirect_to ) : is_valid = True if ( ( not redirect_to ) or ( ' ' in redirect_to ) ) : is_valid = False elif ( '//' in redirect_to ) : allowed_domains = getattr ( settings , 'ALLOWED_EXTERNAL_OPENID_REDIRECT_DOMAINS' , [ ] ) ( s , netloc , p , q , f ) = urlsplit ( redirect_to ) if netloc : if ( netloc . find ( ':' ) != ( - 1 ) ) : ( netloc , _ ) = netloc . split ( ':' , 1 ) if ( netloc not in allowed_domains ) : is_valid = False if ( not is_valid ) : redirect_to = settings . LOGIN_REDIRECT_URL return redirect_to
sanitise the redirection url .