a †oeÇ7ã@súddlmZddlZddlmZddlmZddlmZgd¢Z dZ e  d ¡Z e  d ¡Z e  d ejejB¡Zd Zd Zdjeed�ZeedœZgd¢ZdZdd dd„eDƒ¡dZdedZdededZdZe  d¡Ze  ded¡Ze  ded¡Ze  ded¡Z e  dedd …d¡Z!e  d!ed"¡Z"d#eeefZ#e  e#ejejB¡Z$e%d$ƒZ&e%d%ƒZ'e&e'Bd&hBZ(e(d'd(hBZ)e)d)hBZ*Z+Gd*d+„d+ed+e ƒƒZ,d,d-„Z-d=d/d0„Z.d1d2„Z/d3d4„Z0d5d6„Z1d7d8„Z2d9d:„Z3d;d<„Z4dS)>é)Úabsolute_importN)Ú namedtupleé)ÚLocationParseError)Úsix©ÚschemeÚauthÚhostÚportÚpathÚqueryÚfragment)ÚhttpÚhttpsNz%[a-fA-F0-9]{2}z^(?:[a-zA-Z][a-zA-Z0-9+-]*:|/)zS^(?:([a-zA-Z][a-zA-Z0-9+.-]*):)?(?://([^\\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?$z(?:[0-9]{1,3}\.){3}[0-9]{1,3}z[0-9A-Fa-f]{1,4}z(?:{hex}:{hex}|{ipv4}))ÚhexZipv4)rZls32) z(?:%(hex)s:){6}%(ls32)sz::(?:%(hex)s:){5}%(ls32)sz%(?:%(hex)s)?::(?:%(hex)s:){4}%(ls32)sz2(?:(?:%(hex)s:)?%(hex)s)?::(?:%(hex)s:){3}%(ls32)sz6(?:(?:%(hex)s:){0,2}%(hex)s)?::(?:%(hex)s:){2}%(ls32)sz/(?:(?:%(hex)s:){0,3}%(hex)s)?::%(hex)s:%(ls32)sz'(?:(?:%(hex)s:){0,4}%(hex)s)?::%(ls32)sz&(?:(?:%(hex)s:){0,5}%(hex)s)?::%(hex)sz(?:(?:%(hex)s:){0,6}%(hex)s)?::zCABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._\-~z(?:ú|cCsg|] }|t‘qS©)Ú_subs©Ú.0Úxrrú1C:\Program Files\Certbot\pkgs\urllib3\util\url.pyÚ 6órú)z (?:%25|%)(?:[z]|%[a-fA-F0-9]{2})+z\[z)?\]z!(?:[^\[\]%:/?#]|%[a-fA-F0-9]{2})*z!^(/[^?#]*)(?:\?([^#]*))?(?:#.*)?$ú^ú$éþÿÿÿú(z)\]$z)^(%s|%s|%s)(?::0*?(|0|[1-9][0-9]{0,4}))?$zBABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-~z !$&'()*+,;=ú:ú@ú/ú?cs^eZdZdZdZd‡fdd„ Zedd„ƒZedd „ƒZed d „ƒZ ed d „ƒZ dd„Z ‡Z S)ÚUrlzÍ Data structure for representing an HTTP URL. Used as a return value for :func:`parse_url`. Both the scheme and host are normalized as they are both case-insensitive according to RFC 3986. rNc sD|r| d¡sd|}|dur&| ¡}tt|ƒ ||||||||¡S)Nr")Ú startswithÚlowerÚsuperr$Ú__new__)Úclsrr r r r r r©Ú __class__rrr([s  ÿz Url.__new__cCs|jS)z@For backwards-compatibility with urlparse. We're nice like that.)r ©ÚselfrrrÚhostnamemsz Url.hostnamecCs&|jpd}|jdur"|d|j7}|S)z)Absolute path including the query string.r"Nr#)r r )r-ZurirrrÚ request_urirs  zUrl.request_uricCs|jrd|j|jfS|jS)z(Network location including host and portz%s:%d)r r r,rrrÚnetloc|sz Url.netlocc Cs¢|\}}}}}}}d}|dur*||d7}|dur>||d7}|durN||7}|durf|dt|ƒ7}|durv||7}|durŠ|d|7}|durž|d|7}|S)aˆ Convert self into a url This function should more or less round-trip with :func:`.parse_url`. The returned url may not be exactly the same as the url inputted to :func:`.parse_url`, but it should be equivalent by the RFC (e.g., urls with a blank port will have : removed). Example: :: >>> U = parse_url('http://google.com/mail/') >>> U.url 'http://google.com/mail/' >>> Url('http', 'username:password', 'host.com', 80, ... '/path', 'query', 'fragment').url 'http://username:password@host.com:80/path?query#fragment' ÚNz://r!r r#ú#)Ústr) r-rr r r r r rÚurlrrrr4ƒs"    zUrl.urlcCs|jS©N)r4r,rrrÚ__str__«sz Url.__str__)NNNNNNN) Ú__name__Ú __module__Ú __qualname__Ú__doc__Ú __slots__r(Úpropertyr.r/r0r4r6Ú __classcell__rrr*rr$Rs&ø    'r$cCsvd}d}|D]0}| |¡}|dkr$q |dus4||kr |}|}q |dusN|dkrX|ddfS|d|…||dd…|fS)aì .. deprecated:: 1.25 Given a string and an iterable of delimiters, split on the first found delimiter. Return two split parts and the matched delimiter. If not found, then the first part is the full input string. Example:: >>> split_first('foo/bar?baz', '?/=') ('foo', 'bar?baz', '/') >>> split_first('foo/bar?baz', '123') ('foo/bar?baz', '', None) Scales linearly with number of delims. Not ideal for large number of delims. Nrr1é)Úfind)ÚsZdelimsZmin_idxZ min_delimÚdÚidxrrrÚ split_first¯s  rCúutf-8c CsÒ|dur |St |¡}t dd„|¡\}}| dd¡}|| d¡k}tƒ}tdt|ƒƒD]n}|||d…}t |ƒ} |r€|dks”| d krž|  ¡|vrž||7}qX|  dt | ƒd d… ¡  d ¡ ¡¡qX|  |¡S) zfPercent-encodes a URI component without reapplying onto an already percent-encoded component. NcSs| d¡ ¡S)Nr)ÚgroupÚupper)ÚmatchrrrÚßrz'_encode_invalid_chars..rDÚ surrogatepassó%rr>é€r)rÚ ensure_textÚ PERCENT_REÚsubnÚencodeÚcountÚ bytearrayÚrangeÚlenÚordÚdecodeÚextendrÚzfillrF) Z componentZ allowed_charsÚencodingZpercent_encodingsZ uri_bytesZis_percent_encodedZencoded_componentÚiZbyteZbyte_ordrrrÚ_encode_invalid_charsÒs* ÿ  ÿ ÿ*rZcCs„| d¡}g}|D]0}|dkr"qq|dkr6| |¡q|r| ¡q| d¡rf|rZ|drf| dd¡| d¡rz| d¡d |¡S)Nr"Ú.z..rr1)z/.z/..)ÚsplitÚappendÚpopr%ÚinsertÚendswithÚjoin)r ÚsegmentsÚoutputZsegmentrrrÚ_remove_path_dot_segmentsôs      rdcCsê|ræt|tjƒrt |¡}|tvræt |¡}|r¼t |¡}|r²|  d¡\}}|||…}|  d¡rx|dkrx|dd…}n |dd…}dt |t ƒ}|d|…  ¡|||d…S|  ¡Sn*t |¡sæt d dd„| d¡Dƒ¡¡S|S) Nr>z%25éú%ó.cSsg|] }t|ƒ‘qSr)Ú _idna_encode)rZlabelrrrr,rz#_normalize_host..r[)Ú isinstancerZ binary_typeÚ ensure_strÚNORMALIZABLE_SCHEMESÚ IPV6_ADDRZ_RErGÚ ZONE_ID_REÚsearchÚspanr%rZÚUNRESERVED_CHARSr&ÚIPV4_RErar\)r rZis_ipv6rGÚstartÚendZzone_idrrrÚ_normalize_hosts*         ÿrtcCs”|r†tdd„|Dƒƒr†z ddl}Wn"tyDt tdƒd¡Yn0z|j| ¡ddd�WS|jy„t td|ƒd¡Yn0| ¡ d¡S) Ncss|]}t|ƒdkVqdS)rKN)rTrrrrÚ 2rz_idna_encode..rz-Unable to parse URL without the 'idna' moduleT)ÚstrictZ std3_rulesz#Name '%s' is not a valid IDNA labelÚascii) ÚanyÚidnaÚ ImportErrorrÚ raise_fromrrOr&Z IDNAError)Únameryrrrrh1s  þ  ÿ rhcCs>t |¡ ¡\}}t|tƒ}t|tƒ}|dur:|d|7}|S)zHPercent-encodes a request target so that there are no invalid charactersNr#)Ú TARGET_RErGÚgroupsrZÚ PATH_CHARSÚ QUERY_CHARS)Útargetr r rrrÚ_encode_targetCs    r‚c sÜ|s tƒS|}t |¡s d|}�zt |¡ ¡\}}}}}|dupN| ¡tv}|r\| ¡}|rª| d¡\}} } |pvd}t  | ¡ ¡\} } |rœ|rœt |t ƒ}| dkr´d} n d\}} } | durât | ƒ} d| krØdksânt |ƒ‚t| |ƒ} |�r |�r t|ƒ}t |tƒ}|�r |�r t |tƒ}|�r6|�r6t |tƒ}Wn(ttf�y`t t |ƒd¡YS0|�s†|du�s||du�r‚d}nd}t|tjƒ�rœtj‰ntj‰‡fdd „} t| |ƒ| |ƒ| | ƒ| | |ƒ| |ƒ| |ƒd �S) a Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is performed to parse incomplete urls. Fields not provided will be None. This parser is RFC 3986 and RFC 6874 compliant. The parser logic and helper functions are based heavily on work done in the ``rfc3986`` module. :param str url: URL to parse into a :class:`.Url` namedtuple. Partly backwards-compatible with :mod:`urlparse`. Example:: >>> parse_url('http://google.com/mail/') Url(scheme='http', host='google.com', port=None, path='/mail/', ...) >>> parse_url('google.com:80') Url(scheme=None, host='google.com', port=80, path=None, ...) >>> parse_url('/foo?bar') Url(scheme=None, host=None, port=None, path='/foo', query='bar', ...) z//Nr!r1)NNNriÿÿcs|dur |Sˆ|ƒSr5r)r©Z ensure_funcrrÚ ensure_type szparse_url..ensure_typer)r$Ú SCHEME_RErnÚURI_RErGr~r&rkÚ rpartitionÚ _HOST_PORT_RErZÚUSERINFO_CHARSÚintrrtrdrr€ÚFRAGMENT_CHARSÚ ValueErrorÚAttributeErrorrr{riZ text_typerLrj)r4Z source_urlrZ authorityr r rZ normalize_urir Ú_Ú host_portr r r„rrƒrÚ parse_urlMsd          ùr�cCst|ƒ}|jpd|j|jfS)z4 Deprecated. Use :func:`parse_url` instead. r)r�rr.r )r4ÚprrrÚget_host®sr’)rD)5Z __future__rÚreÚ collectionsrÚ exceptionsrZpackagesrZ url_attrsrkÚcompilerMr…ÚUNICODEÚDOTALLr†ZIPV4_PATZHEX_PATÚformatZLS32_PATrZ _variationsZUNRESERVED_PATraZIPV6_PATZ ZONE_ID_PATZIPV6_ADDRZ_PATZ REG_NAME_PATr}rqZIPV6_RErlZBRACELESS_IPV6_ADDRZ_RErmZ_HOST_PORT_PATrˆÚsetrpZSUB_DELIM_CHARSr‰rr€r‹r$rCrZrdrtrhr‚r�r’rrrrÚsd       ú    ýÿ ]# " a