a [f @sddlZddlZddlmZejejdZdjedZdd dd d e e d d DZ d Z dje e dZdjeedZedZeeZGdddeZddZdS)N)unquote_stringz!#$%&'*+.^_`|~-z [{tchar}]+)tcharz[{0}]ccs|]}t|VqdSN)chr).0cr t/sparta/input/_build_configuration/image_build+validate/lib/bmcenv/lib64/python3.9/site-packages/falcon/forwarded.py "r ) !#z \\[\t !-~]z"(?:{quoted_pair}|{qdtext})*")qdtext quoted_pairz#({token})=({token}|{quoted_string}))token quoted_stringz \\([\t !-~])c@seZdZdZdZddZdS) Forwardeda9Represents a parsed Forwarded header. (See also: RFC 7239, Section 4) Attributes: src (str): The value of the "for" parameter, or ``None`` if the parameter is absent. Identifies the node making the request to the proxy. dest (str): The value of the "by" parameter, or ``None`` if the parameter is absent. Identifies the client-facing interface of the proxy. host (str): The value of the "host" parameter, or ``None`` if the parameter is absent. Provides the host request header field as received by the proxy. scheme (str): The value of the "proto" parameter, or ``None`` if the parameter is absent. Indicates the protocol that was used to make the request to the proxy. srcdesthostschemecCsd|_d|_d|_d|_dSrr)selfr r r __init__NszForwarded.__init__N)__name__ __module__ __qualname____doc__ __slots__rr r r r r4src Cslg}d}t|}d}d}d|kr.|krXnn$t||}|dur|rZ|d|}n|t|d7}d}|\}}|}|ddkrt|}|st}|dkr||_ n2|dkr||_ n"|d kr||_ n|d kr||_ q||dkrd}|d 7}|rV| |d}q||d kr2d}|d 7}q||d vrJ|d 7}q|d|}q|rh| ||S)aParses the value of a Forwarded header. Makes an effort to parse Forwarded headers as specified by RFC 7239: - It checks that every value has valid syntax in general as specified in section 4: either a 'token' or a 'quoted-string'. - It un-escapes found escape sequences. - It does NOT validate 'by' and 'for' contents as specified in section 6. - It does NOT validate 'host' contents (Host ABNF). - It does NOT validate 'proto' contents for valid URI scheme names. Arguments: forwarded (str): Value of a Forwarded header Returns: list: Sequence of Forwarded instances, representing each forwarded-element in the header, in the same order as they appeared in the header. rFN,T"byforrproto;z )len_FORWARDED_PAIR_REmatchfindgroupgroupslowerrrrrrrappend) forwardedelementsposendneed_separatorparsed_elementr,namevaluer r r _parse_forwarded_headerUsR        r:)restringfalcon.util.urirdigits ascii_letters_TCHARformat_TOKENjointuplerange_QDTEXT _QUOTED_PAIR_QUOTED_STRING_FORWARDED_PAIRcompile_QUOTED_PAIR_REPLACE_REr+objectrr:r r r r s(     !