Пример #1
0
def decode_split_uri(uri):
    """uri -- a yelp.uri.SplitResult object"""
    return SplitResult(
        _decode(uri.scheme),
        _decode(uri.username),
        _decode(uri.password),
        _decode_hostname(uri.hostname),  # Decoded below
        _decode(uri.port, encoding='ASCII'),
        _decode(uri.path),
        _decode(uri.query),
        _decode(uri.fragment),
    )
Пример #2
0
def decode_split_email(email):
    """email -- a yelp.email.SplitResult object"""
    return SplitResult(
        _decode(email.scheme),  # Could be "mailto"
        _decode(email.username),
        None,
        _decode_hostname(email.hostname),  # Decoded below
        None,
        None,
        _decode(email.query),  # Subject and body could be here.
        None,
    )
Пример #3
0
def encode_split_uri(uri):
    """uri -- a yelp.uri.SplitResult object"""
    return SplitResult(
        _encode(uri.scheme),
        _encode(uri.username, expected=RFC3986.userinfo),
        _encode(uri.password, expected=RFC3986.userinfo),
        _encode_hostname(uri.hostname),
        _encode(uri.port, encoding='ASCII', expected=RFC3986.digits),
        _encode(uri.path, expected=RFC3986.path),
        _encode(uri.query, expected=RFC3986.query),
        _encode(uri.fragment, expected=RFC3986.fragment),
    )
Пример #4
0
def encode_split_email(email):
    """email -- a yelp.uri.SplitResult object"""
    return SplitResult(
        _encode(email.scheme),  # Could be "mailto"
        # We can't percent-quote email usernames because of the postfix "percent hack"
        # http://www.postfix.org/postconf.5.html#allow_percent_hack
        _encode(email.username, expected=RFC3986.userinfo, encoding=None),
        None,  # Passwords are invalid.
        _encode_hostname(email.hostname),
        None,  # Ports are invalid.
        None,  # Paths are invalid.
        _encode(email.query, expected=RFC3986.query),  # Subject and body could be here.
        None,  # Fragments are invalid
    )