
    j{L                    V   d dl mZ d dlZd dlZd dlmZ d dlmZ ddl	m
Z
 ddlmZ d	Z ej        d
          Z ej        d          Z ej        d          Z ej        d          Z ej        dej        ej        z            ZdZdZd                    ee          ZeedZg dZdZdd                    d eD                       z   dz   Zdez   dz   Zdez   dz   ez   dz   Z dZ! ej        d          Z" ej        d           Z# ej        d!ez   d"z             Z$ ej        d!e z   d"z             Z% ej        d!e dd#         z   d"z             Z& ej        d$ez   d%z             Z'd&e!dede d'Z( ej        e(ej        ej        z            Z) e*d(          Z+ e*d)          Z,e+e,z  d*hz  Z-e-d+d,hz  Z.e.d-hz  xZ/Z0 G d. d/ ej1        d/d0ej2        e3         fd1ej2        e3         fd2ej2        e3         fd3ej2        e4         fd4ej2        e3         fd5ej2        e3         fd6ej2        e3         fg                    Z5ej6        dRd<            Z7ej6        dSd>            Z7dTd@Z7dUdAZ8ej6        dVdB            Z9ej6        dWdC            Z9dXdDZ9dYdHZ:dZdIZ;dYdJZ<d[dMZ=d\dOZ>d]dQZ?dS )^    )annotationsN)partial)unquote   )LocationParseError   )to_str)httphttpsNz%[a-fA-F0-9]{2}z%[a-fA-F0-9]{2}|%z^(?:[a-zA-Z][a-zA-Z0-9+-]*:|/)z[\x00-\x20\x7f]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}))hexipv4)r   ls32)	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(?:|c                "    g | ]}|t           z  S  )_subs).0xs     ?/opt/deyu/venv/lib/python3.11/site-packages/urllib3/util/url.py
<listcomp>r   8   s    ===Aa%i===    )z(?:%25|%)(?:[z]|%[a-fA-F0-9]{2})+z\[z)?\]z!(?:[^\[\]%:/?#]|%[a-fA-F0-9]{2})*z!^(/[^?#]*)(?:\?([^#]*))?(?:#.*)?$zE^(?:0[xX][0-9a-fA-F]+|[0-9]+)(?:\.(?:0[xX][0-9a-fA-F]+|[0-9]+)){0,3}$^$(z)\]$z^(z)(?::0*?(|0|[1-9][0-9]{0,4}))?$zBABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-~z!$&'()*+,;=:@/?c                       e Zd ZdZ	 	 	 	 	 	 	 dd fdZedd            Zedd            Zedd            Zedd            Z	edd            Z
edd            Zedd            ZddZ xZS )Urla  
    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.

    :param auth: User information as defined in RFC 3986 3.2.1. This
        component is kept percent-encoded. Use :attr:`auth_decoded` or
        :attr:`auth_decoded_joined` to get the decoded form.
    Nscheme
str | Noneauthhostport
int | Nonepathqueryfragmentc           
         |r|                     d          sd|z   }||                                }t                                          | |||||||          S )Nr   )
startswithlowersuper__new__)	clsr#   r%   r&   r'   r)   r*   r+   	__class__s	           r   r0   zUrl.__new__n   s`      	,, 	:D\\^^FwwsFD$dE8TTTr   return*tuple[None, None] | tuple[str, str | None]c                    | j         dS | j                             d          \  }}}t          |d          |rt          |d          ndfS )z
        User information with %-escapes decoded as UTF-8, returned as a
        ``(username, password)`` tuple.

        Both values are ``None`` if ``auth`` is ``None``.
        ``password`` is ``None`` if not present in the auth component.
        N)NNr   utf-8)encoding)r%   	partition_unquote)selfusernameseppasswords       r   auth_decodedzUrl.auth_decoded~   sa     9:"&)"5"5c":":#xX00047AHX0000T
 	
r   c                0    | j         \  }}|dS | d|pd S )a  
        User information with %-escapes decoded as UTF-8, as a string
        prepared for encoding into an 'authorization: basic ...' header.

        This property does not choose the encoding used for an
        'authorization: basic ...' header. Use the ``basic_auth_encoding`` or
        ``proxy_basic_auth_encoding`` parameters of
        :func:`urllib3.util.make_headers` when converting the returned string
        into Basic authentication bytes.

        This is a convenience property that joins the username and
        password with a colon, if both are present.
        If only the username is present, a trailing colon is still
        appended.
        If ``auth`` is ``None``, this returns ``None``.
        Nr    )r>   )r:   r;   r=   s      r   auth_decoded_joinedzUrl.auth_decoded_joined   s4    $ ".(4--X^---r   c                    | j         S )z@For backwards-compatibility with urlparse. We're nice like that.)r&   r:   s    r   hostnamezUrl.hostname   s     yr   strc                @    | j         pd}| j        |d| j        z   z  }|S )z)Absolute path including the query string.r   Nr    )r)   r*   )r:   uris     r   request_urizUrl.request_uri   s.     i3:!3##C
r   c                8    | j         }| j        }|||S | d| S )z
        Authority component as defined in RFC 3986 3.2.
        This includes userinfo (auth), host and port.

        i.e.
            userinfo@host:port
        Nr   )r%   netloc)r:   userinforJ   s      r   	authorityzUrl.authority   s5     9>X-M)))))r   c                R    | j         dS | j        | j          d| j         S | j         S )z
        Network location including host and port.

        If you need the equivalent of urllib.parse's ``netloc``,
        use the ``authority`` property instead.
        Nr   )r&   r'   rC   s    r   rJ   z
Url.netloc   s9     949 i--$)---yr   c                    | \  }}}}}}}d}|||dz   z  }|||dz   z  }|||z  }||dt          |          z   z  }|||z  }||d|z   z  }||d|z   z  }|S )a2  
        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:

        .. code-block:: python

            import urllib3

            U = urllib3.util.parse_url("https://google.com/mail/")

            print(U.url)
            # "https://google.com/mail/"

            print( urllib3.util.Url("https", "username:password",
                                    "host.com", 80, "/path", "query", "fragment"
                                    ).url
                )
            # "https://username:password@host.com:80/path?query#fragment"
        r@   Nz://r   r   r    #)rE   )	r:   r#   r%   r&   r'   r)   r*   r+   urls	            r   rP   zUrl.url   s    6 ;?7dD$x 6E>!C4#:C4KC3T?"C4KC3;C3>!C
r   c                    | j         S N)rP   rC   s    r   __str__zUrl.__str__  s	    xr   )NNNNNNN)r#   r$   r%   r$   r&   r$   r'   r(   r)   r$   r*   r$   r+   r$   )r3   r4   )r3   r$   )r3   rE   )__name__
__module____qualname____doc__r0   propertyr>   rA   rD   rH   rL   rJ   rP   rS   __classcell__)r2   s   @r   r"   r"   V   s_         " #U U U U U U U  
 
 
 X
  . . . X.,    X    X * * * X*    X - - - X-^       r   r"   r#   r%   r&   r'   r)   r*   r+   	componentrE   allowed_charstyping.Container[str]r3   c                    d S rR   r   rZ   r[   s     r   _encode_invalid_charsr_     	     Cr   Nonec                    d S rR   r   r^   s     r   r_   r_     r`   r   r$   c                   | | S t          |           } d| vr8|                                 r$t          t          |j        |                     r| S t
                              d |           \  } }|                     dd          }||                    d          k    }t                      }|D ]?}|r|dk    s|dk     r't          |          |v r|                    |           7|d	|z  z  }@|                                S )
zfPercent-encodes a URI component without reapplying
    onto an already percent-encoded component.
    N%c                P    |                      d                                          S Nr   groupuppermatchs    r   <lambda>z'_encode_invalid_chars.<locals>.<lambda>0  s    ekk!nn**,, r   r6   surrogatepass   %%      s   %%%02X)r	   isasciiallmap__contains___PERCENT_REsubnencodecount	bytearraychrappenddecode)rZ   r[   percent_encodings	uri_bytesis_percent_encodedencoded_componentbyte_ords          r   r_   r_     s8    y!!I 	9 	M.	::;; 	 
 $/#3#3,,i$ $ I    /::I*iood.C.CC!  6 6 	68t#3#3sNNs8}}==$$X....X!55##%%%r   c                   |                      d          }g }|D ];}|dk    r	|dk    r|                    |           %|r|                                 <|                     d          r |r|d         r|                    dd           |                     d          r|                    d           d                    |          S )Nr   .z..r   r@   )z/.z/..)splitr{   popr-   insertendswithjoin)r)   segmentsoutputsegments       r   _remove_path_dot_segmentsr   C  s    zz#HF 
 
c>>d??MM'""""  	JJLLL s V vay a }}]## b88Fr   c                    d S rR   r   r&   r#   s     r   _normalize_hostr   a  s    =@Sr   c                    d S rR   r   r   s     r   r   r   e  s    ;>3r   c                   | rt                               |           }|r't          d| d|                                          |t          v rt
                              |           }|rt                              |           }|r|                    d          \  }}| ||         }|	                    d          r|dk    r|dd          }n
|dd          }t                              t          t          |           |          }t          |t                    }| d |                                          d| | |d           S |                                 S t"                              |           sdd| v r t$                              t&          |           } t)          d                    d	 |                     d
          D                       d          S | S )NHost  contains invalid character r   z%25   
error_hostrd      .c                ,    g | ]}t          |          S r   )_idna_encode)r   labels     r   r   z#_normalize_host.<locals>.<listcomp>  s     PPPu|E22PPPr   r   ascii)_HOST_INVALID_CHAR_REsearchr   rh   _NORMALIZABLE_SCHEMES_IPV6_ADDRZ_RErk   _ZONE_ID_REspanr-   ru   subr   #_normalize_zone_id_percent_encodingr_   _UNRESERVED_CHARSr.   _IPV4_RE_HOST_PERCENT_RE _normalize_host_percent_encodingr	   r   r   )r&   r#   invalid_host_charis_ipv6rk   startendzone_ids           r   r   r   i  s    $188>> 	$1 1 1$**,,1 1   ***$**400G  $**400 (!&AJE3"59oG))%00 .W5E5E")!""+")!""+)oo CPTUUU G 4G=NOOG"6E6l0022JJWJd344jJJJ::<<'^^D)) $;;+//0PRVWWDIIPP

3PPPQQ   Kr   rk   re.Match[str]r   c                   |                      d          }t          t          |dd          d                    }|dk     s|dk    rt          d|d|          |S )Nr   r       r   z4 contains invalid percent-encoded control character )rh   rz   intr   )rk   r   percent_encoded_octetdecoded_octets       r   _decode_percent_encodingr     s    !KKNN1!""5r::;;M v&!8!8 ;J ; ;!6; ;
 
 	
 r   c                    |                      d          dk    rt          | j        d          t          | | j                  }|t          v r|S |                      d                                          S )Nr   rd   z is not a valid hostr   )rh   r   stringr   r   ri   )rk   r   s     r   r   r     sr    {{1~~ EL!H!H!HIII,Uu|LLLM)));;q>>!!!r   c               r    t          | |           |                     d                                          S )Nr   r   )r   rh   ri   )rk   r   s     r   r   r     s3     Uz::::;;q>>!!!r   namebytesc                   |                                  sq	 dd l}n# t          $ r t          d          d w xY w	 |                    |                                 dd          S # |j        $ r t          d|  d          d w xY wt                              d |                                                               d          S )	Nr   z-Unable to parse URL without the 'idna' moduleT)strict
std3_ruleszName 'z' is not a valid IDNA labelc                P    |                      d                                          S rf   rg   rj   s    r   rl   z_idna_encode.<locals>.<lambda>  s    Q)=)=)?)? r   r   )	rq   idnaImportErrorr   rw   r.   	IDNAErrorru   r   )r   r   s     r   r   r     s    <<>> 	KKKK 	 	 	$? 	
	;;tzz||DT;JJJ~ 	 	 	$:::: 	
 ????NNUU  s    6)A$ $Btargetc                    t                               |           }|st          | d          |                                \  }}t	          |t
                    }|t	          |t                    }|d|z   z  }|S )zPercent-encodes a request target so that there are no invalid characters

    Pre-condition for this function is that 'target' must start with '/'.
    If that is the case then _TARGET_RE will always produce a match.
    z is not a valid request URINr    )
_TARGET_RErk   r   groupsr_   _PATH_CHARS_QUERY_CHARS)r   rk   r)   r*   encoded_targets        r   _encode_targetr     s     V$$E K F!I!I!IJJJ,,..KD%*4==N%e\::#+%r   rP   c           	     F   | st                      S t                              |           sd| z   } t                              |                                           \  }}}}}|du p|                                t          v }|r|                                }|r|                    d          \  }}}	|pd}t          
                    |	          }
|
sUt                              |	          }|r't          d|	d|                                          t          |	d          |
                                \  }}|r|rt          |t                    }|dk    rd}nd\  }}}|.t!          |          }d	|cxk    rd
k    sn t          |           nd}t#          ||          }|r&|r$t%          |          }t          |t&                    }|r|rt          |t(                    }|r|rt          |t*                    }|s	||d}nd}t          |||||||          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:`urllib.parse`.

    Example:

    .. code-block:: python

        import urllib3

        print( urllib3.util.parse_url('http://google.com/mail/'))
        # Url(scheme='http', host='google.com', port=None, path='/mail/', ...)

        print( urllib3.util.parse_url('google.com:80'))
        # Url(scheme=None, host='google.com', port=80, path=None, ...)

        print( urllib3.util.parse_url('/foo?bar'))
        # Url(scheme=None, host=None, port=None, path='/foo', query='bar', ...)
    z//Nr   r   r   z is not a valid host or portr@   )NNNr   i  )r#   r%   r&   r'   r)   r*   r+   )r"   
_SCHEME_REr   _URI_RErk   r   r.   r   
rpartition_HOST_PORT_RE	fullmatchr   r   rh   r_   _USERINFO_CHARSr   r   r   r   r   _FRAGMENT_CHARS)rP   r#   rL   r)   r*   r+   normalize_urir%   _	host_porthost_port_matchr   r&   r'   port_ints                  r   	parse_urlr     s   8  uuS!! Sj 07}}S/A/A/H/H/J/J,FItUHdNMfllnn8M&MM   ,&11#66a|t'11)<< 	S 5 < <Y G G  (5I 5 5(..005 5   %	%Q%Q%QRRR$++--
d 	@M 	@(??D2::D+dDt99X&&&&&&&&$S))) ' 4((D 8 8(..$T;77 ; ;%e\:: D D(?CC   4DDD   r   )rZ   rE   r[   r\   r3   rE   )rZ   ra   r[   r\   r3   ra   )rZ   r$   r[   r\   r3   r$   )r)   rE   r3   rE   )r&   ra   r#   r$   r3   ra   )r&   rE   r#   r$   r3   rE   )r&   r$   r#   r$   r3   r$   )rk   r   r   rE   r3   rE   )rk   r   r3   rE   )r   rE   r3   r   )r   rE   r3   rE   )rP   rE   r3   r"   )@
__future__r   retyping	functoolsr   urllib.parser   r9   
exceptionsr   utilr	   r   compileru   r   r   r   UNICODEDOTALLr   	_IPV4_PAT_HEX_PATformat	_LS32_PATr   _variations_UNRESERVED_PATr   	_IPV6_PAT_ZONE_ID_PAT_IPV6_ADDRZ_PAT_REG_NAME_PATr   r   _IPV6_REr   _BRACELESS_IPV6_ADDRZ_REr   _HOST_PORT_PATr   setr   _SUB_DELIM_CHARSr   r   r   r   
NamedTupleOptionalrE   r   r"   overloadr_   r   r   r   r   r   r   r   r   r   r   r   <module>r      s   " " " " " " 				        , , , , , , + + + + + +       0  bj+,,2:233 RZ9::
"
#566 
"*
 J  -	$++y+II	),,  * YCHH=====>>>D	03HH)#f,|;gE4RZ<==
2:L  2:cIo+,,C/1C788%2:cOAbD,A&AC&GHH bj|+g566 MMIIOO
 
>2:	+ABBCH   3}%% #&66#>c
*!,u!4 4n n n n nFvs+,V_S)*V_S)*V_S)*V_S)*foc*+-.	
 n n nb        +& +& +& +&\   <  @ @ @  @  > > >  >& & & &R
 
 
 
" " " "" " " "   *   $j j j j j jr   