3 f@sdZddlZddlZddlZddlZddddddd d d d d ddddddddddgZddddddddd d!d"d#d$d%d&d'd(d)d*gZdddddd+dddd"d d!d,d#d$d%d-d'd(d&d.d/d0d)d*gZddd1d#ddd d!d$d%d2d3d"d&d4gZdd1d5d6d+ddd,d2d3g Z ddddd d!d"dd$d%d2d3g Z ddd1ddd6ddd d!d,dd#g Z d7Z d8Z d9d:d;gZdZd?Zd@ZdAdBZeefdCdDZeefdEdFZdGdHZGdIdJdJeZGdKdLdLeZGdMdNdNeZGdOdPdPeeZGdQdRdReeZddSlmZeddTZeddUZ eddVZ!dWe_dXej"_dYej#_dZe _d[e j$_d\e j%_d]e j&_d^e j'_d_e j#_d`e!_e j$je!j$_e j%je!j%_e j&je!j&_dae!j(_e j'je!j'_e j#je!j#_eZ)GdbddeeZ*Gdcdde eZ+Gdddde!eZ,GdeddeeZ-Gdfdde eZ.Gdgdde!eZ/dhdiZ0e0[0ddkdZ1dldmZ2ddndoZ3dpdqZ4drdsZ5ddtdZ6dudZ7dvdZ8ddwdZ9dxdZ:dyZ;dad{Z?dd~dZ@ddd ZAGdddeBZCdZDdaEddd ZFdddZGeHdZIeJeIZKiZLGdddejMZNddd ZOddd ZPdddZQddddePfdd ZRddZSddZTdaUddZVdaWddZXddZYddZZda[ddZ\dddZ]ddZ^ddZ_ddZ`ddZadS)a3Parse (absolute and relative) URLs. urlparse module is based upon the following RFC specifications. RFC 3986 (STD66): "Uniform Resource Identifiers" by T. Berners-Lee, R. Fielding and L. Masinter, January 2005. RFC 2732 : "Format for Literal IPv6 Addresses in URL's by R.Hinden, B.Carpenter and L.Masinter, December 1999. RFC 2396: "Uniform Resource Identifiers (URI)": Generic Syntax by T. Berners-Lee, R. Fielding, and L. Masinter, August 1998. RFC 2368: "The mailto URL scheme", by P.Hoffman , L Masinter, J. Zawinski, July 1998. RFC 1808: "Relative Uniform Resource Locators", by R. Fielding, UC Irvine, June 1995. RFC 1738: "Uniform Resource Locators (URL)" by T. Berners-Lee, L. Masinter, M. McCahill, December 1994 RFC 3986 is considered the current standard and any future changes to urlparse module should conform with it. The urlparse module is currently not entirely compliant with this RFC due to defacto scenarios for parsing, and for backward compatibility purposes, some parsing quirks from older RFCs are retained. The testcases in test_urlparse.py provides a good indicator of parsing behavior. The WHATWG URL Parser spec should also be considered. We are not compliant with it either due to existing user code API behavior expectations (Hyrum's Law). It serves as a useful guide when making changes. Nurlparse urlunparseurljoin urldefragurlsplit urlunsplit urlencodeparse_qs parse_qslquote quote_plusquote_from_bytesunquote unquote_plusunquote_to_bytes DefragResult ParseResult SplitResultDefragResultBytesParseResultBytesSplitResultBytesZftphttpZgopherZnntpZimapZwaisfileZhttpsZshttpZmmsZprosperoZrtspZrtspuZsftpZsvnzsvn+sshZwsZwssZtelnetZsnewsZrsyncZnfsZgitzgit+sshZhdlZsipZsipsZtelZmailtoZnewszAabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-.z!     cCstjtjdS)z,Clear the parse cache and the quoters cache.N) _parse_cacheclear _safe_quotersr!r!$/usr/lib64/python3.6/urllib/parse.py clear_cache_sr#asciistrictcCs|S)Nr!)objr!r!r"_noopnsr'cCs |j||S)N)encode)r&encodingerrorsr!r!r"_encode_resultqsr+cstfdd|DS)Nc3s"|]}|r|jndVqdS)rN)decode).0x)r)r*r!r" wsz_decode_args..)tuple)argsr)r*r!)r)r*r" _decode_argsusr2cGsZt|dt}x.|ddD]}|rt|t|krtdqW|rL|tfSt|tfS)Nrz$Cannot mix str and non-str arguments) isinstancestr TypeErrorr'r2r+)r1Z str_inputargr!r!r" _coerce_argsys  r8c@seZdZdZfZdddZdS)_ResultMixinStrz>Standard approach to encoding parsed results from str to bytesr$r%cs|jfdd|DS)Nc3s|]}|jVqdS)N)r()r-r.)r)r*r!r"r/sz)_ResultMixinStr.encode..)_encoded_counterpart)selfr)r*r!)r)r*r"r(sz_ResultMixinStr.encodeN)r$r%)__name__ __module__ __qualname____doc__ __slots__r(r!r!r!r"r9sr9c@seZdZdZfZdddZdS)_ResultMixinBytesz>Standard approach to decoding parsed results from bytes to strr$r%cs|jfdd|DS)Nc3s|]}|jVqdS)N)r,)r-r.)r)r*r!r"r/sz+_ResultMixinBytes.decode..)_decoded_counterpart)r;r)r*r!)r)r*r"r,sz_ResultMixinBytes.decodeN)r$r%)r<r=r>r?r@r,r!r!r!r"rAsrAc@sDeZdZdZfZeddZeddZeddZedd Z d S) _NetlocResultMixinBasezHShared methods for the parsed result objects containing a netloc elementcCs |jdS)Nr) _userinfo)r;r!r!r"usernamesz_NetlocResultMixinBase.usernamecCs |jdS)Nr3)rD)r;r!r!r"passwordsz_NetlocResultMixinBase.passwordcCsD|jd}|sdSt|tr dnd}|j|\}}}|j||S)Nr%%) _hostinfor4r5 partitionlower)r;hostname separatorZpercentZzoner!r!r"rLs  z_NetlocResultMixinBase.hostnamecCs@|jd}|dk rr?r@propertyrErFrLrQr!r!r!r"rCs    rCc@s(eZdZfZeddZeddZdS)_NetlocResultMixinStrcCsD|j}|jd\}}}|r4|jd\}}}|sr@rRrDrIr!r!r!r"rSs rSc@s(eZdZfZeddZeddZdS)_NetlocResultMixinBytescCsD|j}|jd\}}}|r4|jd\}}}|sr@rRrDrIr!r!r!r"ras ra) namedtuplez url fragmentz!scheme netloc path query fragmentz(scheme netloc path params query fragmentz DefragResult(url, fragment) A 2-tuple that contains the url without fragment identifier and the fragment identifier as a separate argument. z$The URL with no fragment identifier.z Fragment identifier separated from URL, that allows indirect identification of a secondary resource by reference to a primary resource and additional identifying information. z SplitResult(scheme, netloc, path, query, fragment) A 5-tuple that contains the different components of a URL. Similar to ParseResult, but does not split params. z%Specifies URL scheme for the request.z0 Network location where the request is made to. z@ The hierarchical path, such as the path to a file to download. z The query component, that contains non-hierarchical data, that along with data in path component, identifies a resource in the scope of URI's scheme and network location. z Fragment identifier, that allows indirect identification of a secondary resource by reference to a primary resource and additional identifying information. zr ParseResult(scheme, netloc, path, params, query, fragment) A 6-tuple that contains components of a parsed URL. z Parameters for last path element used to dereference the URI in order to provide access to perform some operation on the resource. c@seZdZfZddZdS)rcCs |jr|jd|jS|jSdS)N#)fragmenturl)r;r!r!r"geturlDszDefragResult.geturlN)r<r=r>r@rjr!r!r!r"rBsc@seZdZfZddZdS)rcCst|S)N)r)r;r!r!r"rjLszSplitResult.geturlN)r<r=r>r@rjr!r!r!r"rJsc@seZdZfZddZdS)rcCst|S)N)r)r;r!r!r"rjQszParseResult.geturlN)r<r=r>r@rjr!r!r!r"rOsc@seZdZfZddZdS)rcCs |jr|jd|jS|jSdS)N#)rhri)r;r!r!r"rjWszDefragResultBytes.geturlN)r<r=r>r@rjr!r!r!r"rUsc@seZdZfZddZdS)rcCst|S)N)r)r;r!r!r"rj_szSplitResultBytes.geturlN)r<r=r>r@rjr!r!r!r"r]sc@seZdZfZddZdS)rcCst|S)N)r)r;r!r!r"rjdszParseResultBytes.geturlN)r<r=r>r@rjr!r!r!r"rbscCs8ttfttfttff}x|D]\}}||_||_qWdS)N)rrrrrrr:rB)Z _result_pairsZ_decodedZ_encodedr!r!r"_fix_result_transcodinghs  rlTc Csft||\}}}t|||}|\}}}}}|tkrHd|krHt|\}}nd}t||||||} || S)a#Parse a URL into 6 components: :///;?# Return a 6-tuple: (scheme, netloc, path, params, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) and we don't expand % escapes.;r)r8r uses_params _splitparamsr) rischemeallow_fragments_coerce_resultZ splitresultrVqueryrhparamsresultr!r!r"rus cCsRd|kr,|jd|jd}|dkr6|dfSn |jd}|d|||ddfS)N/rmrrr3)findrfind)riir!r!r"ros   rocCsLt|}x*dD]"}|j||}|dkrt||}qW|||||dfS)Nz/?#r)lenrwmin)ristartdelimcZwdelimr!r!r" _splitnetlocs   rcCs| stdd|D rdSddl}|jdd}|jdd}|jdd}|jdd}|jd |}||krndSx(d D] }||krttd |d d qtWdS)Ncss|]}t|dkVqdS)N)ord)r-r~r!r!r"r/sz_checknetloc..rrTrrUrg?NFKCz/?#@:znetloc 'z' contains invalid z#characters under NFKC normalization)any unicodedatareplace normalizerP)rVrnZnetloc2r~r!r!r" _checknetlocs       rcCsxtD]}|j|d}qW|S)Nr)_UNSAFE_URL_BYTES_TO_REMOVEr)ribr!r!r"_remove_unsafe_bytes_from_urls rc Cst||\}}}t|}t|}|jt}|jt}t|}|||t|t|f}tj|d}|rj||St tt kr|t d}}}|j d} | dkr|d| dkr~|d| j }|| dd}|dddkrt|d\}}d |kod |ksd |krd |krtd |r:///?# Return a 5-tuple: (scheme, netloc, path, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) and we don't expand % escapes.NrrUrrr3z//r\r]zInvalid IPv6 URLrgrcss|]}|dkVqdS) 0123456789Nr!)r-r~r!r!r"r/szurlsplit..)r8rlstrip_WHATWG_C0_CONTROL_OR_SPACEstripbooltypergetrzMAX_CACHE_SIZEr#rwrKrrPsplitrr scheme_charsr) rirprqrrkeycachedrVrsrhryvr~restr!r!r"rsd          cCs<t|\}}}}}}}|r&d||f}|t|||||fS)zPut a parsed URL back together again. This may result in a slightly different, but equivalent URL, if the URL that was parsed originally had redundant delimiters, e.g. a ? with an empty query (the draft states that these are equivalent).z%s;%s)r8r) componentsrprVrirtrsrhrrr!r!r"rs cCst|\}}}}}}|s4|r`|tkr`|dddkr`|rP|dddkrPd|}d|pXd|}|rp|d|}|r|d|}|r|d |}||S) akCombine the elements of a tuple as returned by urlsplit() into a complete URL as a string. The data argument can be any five-item iterable. This may result in a slightly different, but equivalent URL, if the URL that was parsed originally had unnecessary delimiters (for example, a ? with an empty query; the RFC states that these are equivalent).Nrz//r3rvrrUrrg)r8 uses_netloc)rrprVrirsrhrrr!r!r"rs    c Cs|s|S|s|St||\}}}t|d|\}}}}}} t|||\} } } } }}| |ks`| tkrh||S| tkr| r|t| | | | ||fS|} | r| r|} |} |s|}|t| | | | ||fS|jd}|ddkr|d=| dddkr| jd}n(|| jd}td|dd |dd <g}xX|D]P}|dkrdy |jWntk r`YnXn|dkrtq0n |j |q0W|d d kr|j d|t| | dj |pd| ||fS) zaJoin a base URL and a possibly relative URL to form an absolute interpretation of the latter.rrvr3N...rrrr)rr) r8r uses_relativerrrfilterpop IndexErrorappendjoin)baserirqrrZbschemeZbnetlocZbpathZbparamsZbqueryZ bfragmentrprVpathrtrsrhZ base_partsZsegmentsZ resolved_pathZsegr!r!r"r sT            c CsTt|\}}d|kr>t|\}}}}}}t|||||df}nd}|}|t||S)zRemoves any existing fragment from URL. Returns a tuple of the defragmented URL and the fragment. If the URL contained no fragments, the second element is the empty string. rgr)r8rrr) rirrsrpaqZfragZdefragr!r!r"rPs Z0123456789ABCDEFabcdefc Cs|s|jdSt|tr"|jd}|jd}t|dkr<|S|dg}|j}tdkrbddtDaxb|ddD]R}y(|t|dd ||d dWqptk r|d||YqpXqpWdj |S) z,unquote_to_bytes('abc%20def') -> b'abc def'.zutf-8rHr3rNcSs4i|],}tD]"}tt||dg||jq qS))_hexdigbytesrOr()r-rrr!r!r" vsz$unquote_to_bytes..r) rr4r5r(rzr _hextobyterKeyErrorr)stringbitsresritemr!r!r"rcs*     z([-]+)utf-8rcCsd|kr|j|S|dkrd}|dkr*d}tj|}|dg}|j}x@tdt|dD],}|t||j|||||dqVWdj|S) aReplace %xx escapes by their single-character equivalent. The optional encoding and errors parameters specify how to decode percent-encoded sequences into Unicode characters, as accepted by the bytes.decode() method. By default, percent-encoded sequences are decoded with UTF-8, and invalid sequences are replaced by a placeholder character. unquote('abc%20def') -> 'abc def'. rGNzutf-8rrr3rr)r_asciirerrangerzrr,r)rr)r*rrrryr!r!r"rs   Fc CsRi}t|||||||d}x2|D]*\} } | |kr@|| j| q | g|| <q W|S)aParse a query given as a string argument. Arguments: qs: percent-encoded query string to be parsed keep_blank_values: flag indicating whether blank values in percent-encoded queries should be treated as blank strings. A true value indicates that blanks should be retained as blank strings. The default false value indicates that blank values are to be ignored and treated as if they were not included. strict_parsing: flag indicating what to do with parsing errors. If false (the default), errors are silently ignored. If true, errors raise a ValueError exception. encoding and errors: specify how to decode percent-encoded sequences into Unicode characters, as accepted by the bytes.decode() method. max_num_fields: int. If set, then throws a ValueError if there are more than n fields read by parse_qsl(). Returns a dictionary. )r)r*max_num_fieldsrM)r r) qskeep_blank_valuesstrict_parsingr)r*rrMZ parsed_resultpairsnamevaluer!r!r"r sc@seZdZdZdS)_QueryStringSeparatorWarningz>Warning for using default `separator` in parse_qs or parse_qslN)r<r=r>r?r!r!r!r"rsrz/etc/python/urllib.cfgcCst|\}}t|tr |jd}| s6t|ttf rF|dk rFtdt}|dkrVt}d} |dkrvtj j | }d} |dkry t t } Wnt k rYnJX| :ddl} | jdd'd} | j| | j d | dd }|aWdQRXt } |dkrd |krdd lm}|d-tddd}n:|dkr,|}n*t|dkrVt| d| ddd|dk r||krd|jd|jd }nd|j|}||krtd||krdd|jdD}nd d|j|D}g}x|D]}| r| rq|jd!d}t|dkr>|r(td"|f|r|jd#nqt|dsR|r|djd$d%}t|||d&}||}|djd$d%}t|||d&}||}|j||fqW|S).aParse a query given as a string argument. Arguments: qs: percent-encoded query string to be parsed keep_blank_values: flag indicating whether blank values in percent-encoded queries should be treated as blank strings. A true value indicates that blanks should be retained as blank strings. The default false value indicates that blank values are to be ignored and treated as if they were not included. strict_parsing: flag indicating what to do with parsing errors. If false (the default), errors are silently ignored. If true, errors raise a ValueError exception. encoding and errors: specify how to decode percent-encoded sequences into Unicode characters, as accepted by the bytes.decode() method. max_num_fields: int. If set, then throws a ValueError if there are more than n fields read by parse_qsl(). Returns a list, as G-d intended. r$Nz*Separator must be of type string or bytes.ZPYTHON_URLLIB_QS_SEPARATORzenvironment variablerrg)Z interpolationZcomment_prefixesr )Zfallbackrm)warnz4The default separator of urllib.parse.parse_qsl and z1parse_qs was changed to '&' to avoid a web cache z"poisoning issue (CVE-2021-23336). z4By default, semicolons no longer act as query field z separators. z3See https://access.redhat.com/articles/5860431 for z more details.r) stacklevel&Zlegacyr3z (from z) must contain z1 character, or "legacy". See z-szparse_qsl..cSsg|]}|qSr!r!)r-rr!r!r"r/s=zbad query field: %rr+ )r)r*)rgzeThe default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache zThe default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache poisoning issue (CVE-2021-23336). zThe default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache poisoning issue (CVE-2021-23336). By default, semicolons no longer act as query field zThe default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache poisoning issue (CVE-2021-23336). By default, semicolons no longer act as query field separators. zThe default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache poisoning issue (CVE-2021-23336). By default, semicolons no longer act as query field separators. See https://access.redhat.com/articles/5860431 for aThe default separator of urllib.parse.parse_qsl and parse_qs was changed to '&' to avoid a web cache poisoning issue (CVE-2021-23336). By default, semicolons no longer act as query field separators. See https://access.redhat.com/articles/5860431 for more details.)r8r4rr,r5rPobject_default_qs_separatorosenvironropen_QS_SEPARATOR_CONFIG_FILENAMEFileNotFoundError configparserZ ConfigParserZ read_filewarningsrrrzcountrrrr)rrrr)r*rrMrrZ_legacyZ envvar_nameZ config_sourcerrconfigr num_fieldsrrZ name_valueZnvrrr!r!r"r s                   cCs|jdd}t|||S)zLike unquote(), but also replace plus signs by spaces, as required for unquoting HTML form values. unquote_plus('%7e/abc+def') -> '~/abc def' rr)rr)rr)r*r!r!r"rGs sAABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-c@s(eZdZdZddZddZddZdS) QuoterzA mapping from bytes (in range(0,256)) to strings. String values are percent-encoded byte values, unless the key < 128, and in the "safe" set (either the specified safe set, or default set). cCstj||_dS)zsafe: bytes object.N) _ALWAYS_SAFEunionsafe)r;rr!r!r"__init___szQuoter.__init__cCsd|jjt|fS)Nz<%s %r>) __class__r<dict)r;r!r!r"__repr__cszQuoter.__repr__cCs(||jkrt|ndj|}|||<|S)Nz%{:02X})rchrformat)r;rrr!r!r" __missing__gszQuoter.__missing__N)r<r=r>r?rrrr!r!r!r"rWsrrvcCsbt|tr8|s|S|dkrd}|dkr*d}|j||}n |dk rHtd|dk rXtdt||S)aquote('abc def') -> 'abc%20def' Each part of a URL, e.g. the path info, the query, etc., has a different set of reserved characters that must be quoted. RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists the following reserved characters. reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," Each of these characters is reserved in some component of a URL, but not necessarily in all of them. By default, the quote function is intended for quoting the path section of a URL. Thus, it will not encode '/'. This character is reserved, but in typical usage the quote function is being called on a path where the existing slash characters are used as reserved characters. string and safe may be either str or bytes objects. encoding and errors must not be specified if string is a bytes object. The optional encoding and errors parameters specify how to deal with non-ASCII characters, as accepted by the str.encode method. By default, encoding='utf-8' (characters are encoded with UTF-8), and errors='strict' (unsupported characters raise a UnicodeEncodeError). Nzutf-8r%z,quote() doesn't support 'encoding' for bytesz*quote() doesn't support 'errors' for bytes)r4r5r(r6r )rrr)r*r!r!r"r ms cCsdt|trd|ks$t|tr2d|kr2t||||St|trBd}nd}t|||||}|jddS)zLike quote(), but also replace ' ' with '+', as required for quoting HTML form values. Plus signs in the original string are escaped unless they are included in safe. It also does not have safe default to '/'. r r)r4r5rr r)rrr)r*Zspacer!r!r"r s c st|ttfstd|sdSt|tr6|jdd}ntdd|D}|jt|s^|jSy t |Wn&t k rt |j t |<YnXdj fdd|DS)zLike quote(), but accepts a bytes object rather than a str, and does not perform string-to-bytes encoding. It always returns an ASCII string. quote_from_bytes(b'abc def?') -> 'abc%20def%3f' z!quote_from_bytes() expected bytesrr$ignorecSsg|]}|dkr|qS)r!)r-r~r!r!r"rsz$quote_from_bytes..csg|] }|qSr!r!)r-char)quoterr!r"rs)r4r bytearrayr6r5r(rstrip_ALWAYS_SAFE_BYTESr,r rr __getitem__r)Zbsrr!)rr"r s  cCst|dr|j}nRy t|r2t|dt r2tWn0tk rdtj\}}}tdj|YnXg} |sxr|D]j\} } t| t r|| |} n|t | |||} t| t r|| |} n|t | |||} | j | d| qtWn,x(|D]\} } t| t r|| |} n|t | |||} t| t rL|| |} | j | d| qt| t rz|| |||} | j | d| qy t| } Wn:tk r|t | |||} | j | d| YqXxJ| D]B} t| t r|| |} n|t | |||} | j | d| qWqWdj | S)a^Encode a dict or sequence of two-element tuples into a URL query string. If any values in the query arg are sequences and doseq is true, each sequence element is converted to a separate parameter. If the query arg is a sequence of two-element tuples, the order of the parameters in the output will match the order of parameters in the input. The components of a query arg may each be either a string or a bytes type. The safe, encoding, and errors parameters are passed down to the function specified by quote_via (encoding and errors only if a component is a str). itemsrz1not a valid non-string sequence or mapping objectrr) hasattrrrzr4r0r6sysexc_infowith_tracebackrr5rr)rsZdoseqrr)r*Z quote_viaZtyZvatblkrr.Zeltr!r!r"rsP                c CsJt|trFy|jdj}Wn(tk rDtdt|dYnX|S)zto_bytes(u"URL") --> 'URL'.ASCIIzURL z contains non-ASCII characters)r4r5r(r, UnicodeErrorrepr)rir!r!r"to_bytess  rcCs`t|j}|dddkr<|dddkr<|ddj}|dddkr\|ddj}|S) z8unwrap('') --> 'type://host/path'.Nr3<>zURL:rr)r5r)rir!r!r"unwraps   rcCsDtdkrtjdtjatj|}|r<|j\}}|j|fSd|fS)z:splittype('type:opaquestring') --> 'type', 'opaquestring'.Nz ([^/:]+):(.*)) _typeprogrecompileDOTALLmatchgroupsrK)rirrpdatar!r!r" splittype&s   rcCsXtdkrtjdtjatj|}|rP|j\}}|rH|ddkrHd|}||fSd|fS)z;splithost('//host[:port]/path') --> 'host[:port]', '/path'.Nz//([^/#?]*)(.*)rrv) _hostprogrrrrr)rirZ host_portrr!r!r" splithost3s  rcCs |jd\}}}|r|nd|fS)zJsplituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.rTN)rW)hostuserr}r!r!r" splituserAsr cCs |jd\}}}||r|ndfS)z/splitpasswd('user:passwd') -> 'user', 'passwd'.rUN)rJ)rr}Zpasswdr!r!r" splitpasswdFsr cCsDtdkrtjdtjatj|}|r<|j\}}|r<||fS|dfS)z*splitport('host:port') --> 'host', 'port'.Nz(.*):([0-9]*)$) _portprogrrrrr)rrrQr!r!r" splitportMs  r r3c CsT|jd\}}}|s|}n2|rLy t|}Wntk rBd}YnX||fS||fS)zSplit host and port, returning numeric port. Return given default port if no ':' found; defaults to -1. Return numerical port if a valid number are found after ':'. Return None if ':' but not a valid number.rUN)rWrOrP)rZdefportr}rQZnportr!r!r" splitnportZs  r cCs$|jd\}}}|r||fS|dfS)z/splitquery('/path?query') --> '/path', 'query'.rN)rW)rirr}rsr!r!r" splitqueryjsrcCs$|jd\}}}|r||fS|dfS)z)splittag('/path#tag') --> '/path', 'tag'.rgN)rW)rirr}tagr!r!r"splittagqsrcCs|jd}|d|ddfS)zksplitattr('/path;attr1=value1;attr2=value2;...') -> '/path', ['attr1=value1', 'attr2=value2', ...].rmrr3N)r)riZwordsr!r!r" splitattrxs rcCs |jd\}}}||r|ndfS)z-splitvalue('attr=value') --> 'attr', 'value'.rN)rJ)attrr}rr!r!r" splitvalue~sr)rT)r)rT)T)rr)FFrrNN)FFrrNN)rr)rvNN)rNN)rvr)r)br?rrr collections__all__rrrnZnon_hierarchicalZ uses_queryZ uses_fragmentrrrrrr#Z_implicit_encodingZ_implicit_errorsr'r+r2r8rr9rArCrSrarfZ_DefragResultBaseZ_SplitResultBaseZ_ParseResultBaserirhrprVrrsrtZ ResultBaserrrrrrrlrrorrrrrrrrrrrrrrr RuntimeWarningrrrr r frozensetrrrr defaultdictrr r r rrrrrrrr r r r r rrrrr!r!r!r" s                 !           @  E   & y  ,   O