3 f@sddlZddlZddlZddlZdddddddd d d d d dddddddddgZdddddddddd d!d"d#d$d%d&d'd(d)gZdddddd*dddd!dd d+d"d#d$d,d&d'd%d-d.d/d(d)gZddd0d"dddd d#d$d1d2d!d%d3gZdd0d4d5d*ddd+d1d2g Zdddddd d!dd#d$d1d2g Z ddd0ddd5dddd d+dd"g Z d6Z d7Z d8d9d:gZ d;ZiZdZd?Zd@dAZeefdBdCZeefdDdEZdFdGZGdHdIdIeZGdJdKdKeZGdLdMdMeZGdNdOdOeeZGdPdQdQeeZddRlmZeddSZeddTZeddUZ dVe_!dWej"_!dXej#_!dYe_!dZej$_!d[ej%_!d\ej&_!d]ej'_!d^ej#_!d_e _!ej$j!e j$_!ej%j!e j%_!ej&j!e j&_!d`e j(_!ej'j!e j'_!ej#j!e j#_!eZ)GdaddeeZ*GdbddeeZ+Gdcdde eZ,GddddeeZ-GdeddeeZ.Gdfdde eZ/dgdhZ0e0[0ddjdZ1dkdlZ2ddmdnZ3dodpZ4dqdrZ5ddsdZ6dtdZ7dudZ8ddvdZ9dwdZ:dxZ;dadzZ?dd}dZ@ddd ZAGdddeBZCdZDdaEddd ZFdddZGeHdZIeJeIZKiZLGdddejMZNddd ZOddd ZPddd ZQd~dddePfddZRddZSddZTdaUddZVdaWddZXddZYddZZda[ddZ\dddZ]ddZ^ddZ_ddZ`ddZadS)Nurlparse urlunparseurljoin urldefragurlsplit urlunsplit urlencodeparse_qs parse_qslquote quote_plusquote_from_bytesunquote unquote_plusunquote_to_bytes DefragResult ParseResult SplitResultDefragResultBytesParseResultBytesSplitResultBytesZftphttpZgopherZnntpZimapZwaisfileZhttpsZshttpZmmsZprosperoZrtspZrtspuZsftpZsvnzsvn+sshZwsZwssZtelnetZsnewsZrsyncZnfsZgitzgit+sshZhdlZsipZsipsZtelZmailtoZnewszAabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-.z!     cCstjtjdS)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@seZdZfZdddZdS)_ResultMixinStrr$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__ __slots__r(r!r!r!r"r9sr9c@seZdZfZdddZdS)_ResultMixinBytesr$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@sr@c@s@eZdZfZeddZeddZeddZeddZd S) _NetlocResultMixinBasecCs |jdS)Nr) _userinfo)r;r!r!r"usernamesz_NetlocResultMixinBase.usernamecCs |jdS)Nr3)rC)r;r!r!r"passwordsz_NetlocResultMixinBase.passwordcCsD|jd}|sdSt|tr dnd}|j|\}}}|j||S)Nr%%) _hostinfor4r5 partitionlower)r;hostname separatorZpercentZzoner!r!r"rKs  z_NetlocResultMixinBase.hostnamecCs@|jd}|dk rr?propertyrDrErKrPr!r!r!r"rBs    rBc@s(eZdZfZeddZeddZdS)_NetlocResultMixinStrcCsD|j}|jd\}}}|r4|jd\}}}|sr?rQrCrHr!r!r!r"rRs rRc@s(eZdZfZeddZeddZdS)_NetlocResultMixinBytescCsD|j}|jd\}}}|r4|jd\}}}|sr?rQrCrHr!r!r!r"r`s r`) 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?rir!r!r!r"rBsc@seZdZfZddZdS)rcCst|S)N)r)r;r!r!r"riLszSplitResult.geturlN)r<r=r>r?rir!r!r!r"rJsc@seZdZfZddZdS)rcCst|S)N)r)r;r!r!r"riQszParseResult.geturlN)r<r=r>r?rir!r!r!r"rOsc@seZdZfZddZdS)rcCs |jr|jd|jS|jSdS)N#)rgrh)r;r!r!r"riWszDefragResultBytes.geturlN)r<r=r>r?rir!r!r!r"rUsc@seZdZfZddZdS)rcCst|S)N)r)r;r!r!r"ri_szSplitResultBytes.geturlN)r<r=r>r?rir!r!r!r"r]sc@seZdZfZddZdS)rcCst|S)N)r)r;r!r!r"ridszParseResultBytes.geturlN)r<r=r>r?rir!r!r!r"rbscCs8ttfttfttff}x|D]\}}||_||_qWdS)N)rrrrrrr:rA)Z _result_pairsZ_decodedZ_encodedr!r!r"_fix_result_transcodinghs  rkTc Csft||\}}}t|||}|\}}}}}|tkrHd|krHt|\}}nd}t||||||} || S)N;r)r8r uses_params _splitparamsr) rhschemeallow_fragments_coerce_resultZ splitresultrUqueryrgparamsresultr!r!r"rus cCsRd|kr,|jd|jd}|dkr6|dfSn |jd}|d|||ddfS)N/rlrrr3)findrfind)rhir!r!r"rns   rncCsLt|}x*dD]"}|j||}|dkrt||}qW|||||dfS)Nz/?#r)lenrvmin)rhstartdelimcZwdelimr!r!r" _splitnetlocs   r~cCs| 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..rrSrrTrf?NFKCz/?#@:znetloc 'z' contains invalid z#characters under NFKC normalization)any unicodedatareplace normalizerO)rUrnZnetloc2r}r!r!r" _checknetlocs       rcCsxtD]}|j|d}qW|S)Nr)_UNSAFE_URL_BYTES_TO_REMOVEr)rhbr!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.)r8rlstrip_WHATWG_C0_CONTROL_OR_SPACEstripbooltypergetryMAX_CACHE_SIZEr#rvrJr~rOsplitrr scheme_charsr) rhrorprqkeycachedrUrrrgrxvr}restr!r!r"rsd          cCs<t|\}}}}}}}|r&d||f}|t|||||fS)Nz%s;%s)r8r) componentsrorUrhrsrrrgrqr!r!r"rs cCst|\}}}}}}|s4|r`|tkr`|dddkr`|rP|dddkrPd|}d|pXd|}|rp|d|}|r|d|}|r|d|}||S) Nrz//r3rurrTrrf)r8 uses_netloc)rrorUrhrrrgrqr!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) Nrrur3...rrrr)rr) r8r uses_relativerrrfilterpop IndexErrorappendjoin)baserhrprqZbschemeZbnetlocZbpathZbparamsZbqueryZ bfragmentrorUpathrsrrrgZ base_partsZsegmentsZ resolved_pathZsegr!r!r"r sT            c CsTt|\}}d|kr>t|\}}}}}}t|||||df}nd}|}|t||S)Nrfr)r8rrr) rhrqsrpaqZfragZdefragr!r!r"rPs Z0123456789ABCDEFabcdefc Cs|s|jdSt|tr"|jd}|jd}t|dkr<|S|dg}|j}tdkrbddtDaxb|ddD]R}y(|t|dd||ddWqptk r|d||YqpXqpWdj |S) Nzutf-8rGr3rcSs4i|],}tD]"}tt||dg||jq qS))_hexdigbytesrNr()r-rrr!r!r" vsz$unquote_to_bytes..r) rr4r5r(ryr _hextobyterKeyErrorr)stringbitsresritemr!r!r"rcs*     z([-]+)utf-8rcCsd|kr|j|S|dkrd}|dkr*d}tj|}|dg}|j}x@tdt|dD],}|t||j|||||dqVWdj|S)NrFzutf-8rrr3rr)r_asciirerrangeryrr,r)rr)r*rrrrxr!r!r"rs   Fc CsRi}t|||||||d}x2|D]*\} } | |kr@|| j| q | g|| <q W|S)N)r)r*max_num_fieldsrL)r r) qskeep_blank_valuesstrict_parsingr)r*rrLZ parsed_resultpairsnamevaluer!r!r"r sc@s eZdZdS)_QueryStringSeparatorWarningN)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}ndd|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)-Nr$z*Separator must be of type string or bytes.ZPYTHON_URLLIB_QS_SEPARATORzenvironment variablerrf)Z interpolationZcomment_prefixesr )Zfallbackrl)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*)rfzeThe 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,r5rOobject_default_qs_separatorosenvironropen_QS_SEPARATOR_CONFIG_FILENAMEFileNotFoundError configparserZ ConfigParserZ read_filewarningsrrrycountrrrr)rrrr)r*rrLrqZ_legacyZ envvar_nameZ config_sourcerrconfigr num_fieldsrrZ name_valueZnvrrr!r!r"r s                   cCs|jdd}t|||S)Nrr)rr)rr)r*r!r!r"rGs sAABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-c@s$eZdZddZddZddZdS)QuotercCstj||_dS)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>rrrr!r!r!r"rWsrrucCsbt|tr8|s|S|dkrd}|dkr*d}|j||}n |dk rHtd|dk rXtdt||S)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)Nr 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)Nz!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)Nitemsrz1not a valid non-string sequence or mapping objectrr) hasattrrryr4r0r6sysexc_infowith_tracebackrr5rr)rrZdoseqrr)r*Z quote_viaZtyZvatblkrr.Zeltr!r!r"rsP                c CsJt|trFy|jdj}Wn(tk rDtdt|dYnX|S)NASCIIzURL z contains non-ASCII characters)r4r5r(r, UnicodeErrorrepr)rhr!r!r"to_bytess  rcCs`t|j}|dddkr<|dddkr<|ddj}|dddkr\|ddj}|S)Nr3<>zURL:rr)r5r)rhr!r!r"unwraps   rcCsDtdkrtjdtjatj|}|r<|j\}}|j|fSd|fS)Nz ([^/:]+):(.*)) _typeprogrecompileDOTALLmatchgroupsrJ)rhrrodatar!r!r" splittype&s   rcCsXtdkrtjdtjatj|}|rP|j\}}|rH|ddkrHd|}||fSd|fS)Nz//([^/#?]*)(.*)rru) _hostprogrrrrr)rhrZ host_portrr!r!r" splithost3s  rcCs |jd\}}}|r|nd|fS)NrS)rV)hostuserr|r!r!r" splituserAsrcCs |jd\}}}||r|ndfS)NrT)rI)rr|Zpasswdr!r!r" splitpasswdFsr cCsDtdkrtjdtjatj|}|r<|j\}}|r<||fS|dfS)Nz(.*):([0-9]*)$) _portprogrrrrr)rrrPr!r!r" splitportMs  r r3c CsT|jd\}}}|s|}n2|rLy t|}Wntk rBd}YnX||fS||fS)NrT)rVrNrO)rZdefportr|rPZnportr!r!r" splitnportZs  r cCs$|jd\}}}|r||fS|dfS)Nr)rV)rhrr|rrr!r!r" splitqueryjsr cCs$|jd\}}}|r||fS|dfS)Nrf)rV)rhrr|tagr!r!r"splittagqsrcCs|jd}|d|ddfS)Nrlrr3)r)rhZwordsr!r!r" splitattrxs rcCs |jd\}}}||r|ndfS)Nr)rI)attrr|rr!r!r" splitvalue~sr)rT)r)rT)T)rr)FFrrNN)FFrrNN)rr)ruNN)rNN)rur)r)brrr collections__all__rrrmZnon_hierarchicalZ uses_queryZ uses_fragmentrrrrrr#Z_implicit_encodingZ_implicit_errorsr'r+r2r8rr9r@rBrRr`reZ_DefragResultBaseZ_SplitResultBaseZ_ParseResultBase__doc__rhrgrorUrrrrsZ ResultBaserrrrrrrkrrnr~rrrrrrrrrrrrrr RuntimeWarningrrrr r frozensetrrrr defaultdictrr r r rrrrrrrrr r r r r rrrr!r!r!r""s                 !           @  E   & y  ,   O