def referrer_allowed(referrer, referrer_acl):
 allow = False
 if referrer_acl:
  rhost = (urlparse((referrer or '')).hostname or 'unknown')
  for mhost in referrer_acl:
   if mhost.startswith('-'):
    mhost = mhost[1:]
    if ((mhost == rhost) or (mhost.startswith('.') and rhost.endswith(mhost))):
     allow = False
   elif ((mhost == '*') or (mhost == rhost) or (mhost.startswith('.') and rhost.endswith(mhost))):
    allow = True
 return allow

def referrer_allowed ( referrer , referrer_acl ) : allow = False if referrer_acl : rhost = ( urlparse ( ( referrer or '' ) ) . hostname or 'unknown' ) for mhost in referrer_acl : if mhost . startswith ( '-' ) : mhost = mhost [ 1 : ] if ( ( mhost == rhost ) or ( mhost . startswith ( '.' ) and rhost . endswith ( mhost ) ) ) : allow = False elif ( ( mhost == '*' ) or ( mhost == rhost ) or ( mhost . startswith ( '.' ) and rhost . endswith ( mhost ) ) ) : allow = True return allow
returns true if the referrer should be allowed based on the referrer_acl list .