(location)
Check that a given keyserver is a known protocol and does not contain
    shell escape characters.

    :param str location: A string containing the default keyserver. This
                         should contain the desired keyserver protocol which
                         is supported by the keyserver, for example, the
                         default is ``'hkp://wwwkeys .pgp.net'``.
    :rtype: :obj:`str` or :obj:`None`
    :returns: A string specifying the protocol and keyserver hostname, if the
              checks passed. If not, returns None.
Check that a given keyserver is a known protocol and does not contain
    shell escape characters.
Check that a given keyserver is a known protocol and does not contain shell escape characters .
def _check_keyserver(location):
    """Check that a given keyserver is a known protocol and does not contain
    shell escape characters.

    :param str location: A string containing the default keyserver. This
                         should contain the desired keyserver protocol which
                         is supported by the keyserver, for example, the
                         default is ``'hkp://wwwkeys .pgp.net'``.
    :rtype: :obj:`str` or :obj:`None`
    :returns: A string specifying the protocol and keyserver hostname, if the
              checks passed. If not, returns None.
    """
    protocols = ['hkp://', 'hkps://', 'http://', 'https://', 'ldap://',
                 'mailto:'] ## xxx feels like i´m forgetting one...
    for proto in protocols:
        if location.startswith(proto):
            url = location.replace(proto, str())
            host, slash, extra = url.partition('/')
            if extra: log.warn("URI text for %s: '%s'" % (host, extra))
            log.debug("Got host string for keyserver setting: '%s'" % host)

            host = _fix_unsafe(host)
            if host:
                log.debug("Cleaned host string: '%s'" % host)
                keyserver = proto + host
                return keyserver
            return None
def _check_keyserver ( location ) : protocols = [ 'hkp://' , 'hkps://' , 'http://' , 'https://' , 'ldap://' , 'mailto:' ] ## xxx feels like i´m forgetting one... for proto in protocols : if location . startswith ( proto ) : url = location . replace ( proto , str ( ) ) host , slash , extra = url . partition ( '/' ) if extra : log . warn ( "URI text for %s: '%s'" % ( host , extra ) ) log . debug ( "Got host string for keyserver setting: '%s'" % host ) host = _fix_unsafe ( host ) if host : log . debug ( "Cleaned host string: '%s'" % host ) keyserver = proto + host return keyserver return None