
    Gds                    d   U d Z ddlmZ ddlZddlZddl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dl	mZ d	d
lmZ d	dlmZ d	dlmZ d	dlmZ d	dlmZ ej        rd	dlmZ  ej        d          ZdZ ee                    d                    ZdZd eD             Z d  e!d          D             Z" G d dej#                  Z$ G d de$          Z% G d de%          Z& G d de%          Z' e            e iZ(de)d <   ddd'Z*dd1Z+ddd3Z,	 ddd9Z-	 	 	 	 ddd@Z. e.            Z/ e.dAdBC          Z0ddDZ1	 	 	 	 dddEZ2	 dddFZ3ddIZ4	 	 	 dddLZ5	 dddMZ6dddNZ7ddRZ8 ej9        dSe8           ddWZ: e;g  e!dX          dYdZR           <                                Z= e:d[e=          Z> e:d\e=d]z             Z? e:d^e=d_z             Z@ e:d`e=daz             ZA	 	 ddddZB	 	 	 dddhZCddiZD	 	 	 	 	 dddqZE	 	 	 	 	 	 dddwZFdd{ZG	 	 	 	 ddd}ZH	 	 	 	 	 dddZI	 dddZJ	 dddZKdS )zFunctions for working with URLs.

Contains implementations of functions from :mod:`urllib.parse` that
handle bytes and strings.
    )annotationsN)quote)unquote)	urlencode)urlsplit)
urlunsplit   )_check_str_tuple)_decode_idna)_make_encode_wrapper)_to_striter_multi_items)datastructuresz^[a-zA-Z0-9+-.]+$zKabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~$!'()*+,;ascii0123456789ABCDEFabcdefc                z    i | ]8}t           D ].}| |                     d           t          | | d          /9S )r      )
_hexdigitsencodeint).0abs      I/var/www/html/t/fyr/venv311/lib/python3.11/site-packages/werkzeug/urls.py
<dictcomp>r   *   si       	  	
 	I!IIWsa999b11       c                @    g | ]}d |d                     d          S )%02Xr   )r   )r   chars     r   
<listcomp>r"   /   s.    DDDn$nnn##G,,DDDr      c                  B    e Zd ZU ded<   ded<   ded<   ded<   ded<   dS )	_URLTuplestrschemenetlocpathqueryfragmentN)__name__
__module____qualname____annotations__ r   r   r%   r%   2   s=         KKKKKKIIIJJJMMMMMr   r%   c                  ~    e Zd ZU dZdZded<   ded<   ded<   ded<   d) fdZd*dZ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e	d,d            Ze	d,d            Zd.dZd)dZd*dZd*dZd*dZd/dZd/d Z	 d0d1d$Zd2d&Zd3d'Zd3d(Z xZS )4BaseURLzSuperclass of :py:class:`URL` and :py:class:`BytesURL`.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use the ``urllib.parse`` library instead.
    r0   r&   _at_colon	_lbracket	_rbracketargst.Anykwargsreturnc                    t          j        d| j         dt          d            t	                      j        | g|R i |S )Nz'werkzeug.urls.z\' is deprecated and will be removed in Werkzeug 3.0. Use the 'urllib.parse' library instead.   
stacklevel)warningswarnr,   DeprecationWarningsuper__new__)clsr7   r9   	__class__s      r   rC   zBaseURL.__new__G   sf    Ecl E E E		
 	
 	
 	
 uwws4T444V444r   c                *    |                                  S N)to_urlselfs    r   __str__zBaseURL.__str__P   s    {{}}r   c                     | j         di |S )zReturn an URL with the same values, except for those parameters
        given new values by whichever keyword arguments are specified.r0   )_replace)rJ   r9   s     r   replacezBaseURL.replaceS   s     t}&&v&&&r   
str | Nonec                6    |                                  d         S )zThe host part of the URL if available, otherwise `None`.  The
        host is either the hostname or the IP address mentioned in the
        URL.  It will not contain the port.
        r   )_split_hostrI   s    r   hostzBaseURL.hostX   s     !!!$$r   c                    | j         }|Ot          |t                    r:	 |                    d                              d          }n# t
          $ r Y nw xY w|S )a   Works exactly like :attr:`host` but will return a result that
        is restricted to ASCII.  If it finds a netloc that is not ASCII
        it will attempt to idna decode it.  This is useful for socket
        operations when the URL might include internationalized characters.
        Nidnar   )rR   
isinstancer&   r   decodeUnicodeErrorrJ   rvs     r   
ascii_hostzBaseURL.ascii_host`   si     Y>jS11>YYv&&--g66   	s   (A	 	
AA
int | Nonec                    	 t          t          |                                 d                             }d|cxk    rdk    rn n|S n# t          t          f$ r Y nw xY wdS )z}The port in the URL as an integer if it was present, `None`
        otherwise.  This does not fill in default ports.
        r	   r   i  N)r   r   rQ   
ValueError	TypeErrorrX   s     r   portzBaseURL.porto   s    
	WT--//23344BB%	I& 	 	 	D	ts   AA	 	AAc                6    |                                  d         S )zSThe authentication part in the URL if available, `None`
        otherwise.
        r   )_split_netlocrI   s    r   authzBaseURL.auth|   s    
 !!##A&&r   c                \    |                                  d         }|t          |          S dS )zThe username if it was part of the URL, `None` otherwise.
        This undergoes URL decoding and will always be a string.
        r   N_split_auth_url_unquote_legacyrX   s     r   usernamezBaseURL.username   2    
 ">&r***tr   c                6    |                                  d         S )zThe username if it was part of the URL, `None` otherwise.
        Unlike :attr:`username` this one is not being decoded.
        r   re   rI   s    r   raw_usernamezBaseURL.raw_username       
 !!!$$r   c                \    |                                  d         }|t          |          S dS )zThe password if it was part of the URL, `None` otherwise.
        This undergoes URL decoding and will always be a string.
        r	   Nrd   rX   s     r   passwordzBaseURL.password   rh   r   c                6    |                                  d         S )zThe password if it was part of the URL, `None` otherwise.
        Unlike :attr:`password` this one is not being decoded.
        r	   rj   rI   s    r   raw_passwordzBaseURL.raw_password   rl   r   ds.MultiDict[str, str]c                ,    t          | j        g|R i |S )zDecodes the query part of the URL.  Ths is a shortcut for
        calling :func:`url_decode` on the query argument.  The arguments and
        keyword arguments are forwarded to :func:`url_decode` unchanged.
        )
url_decoder*   rJ   r7   r9   s      r   decode_queryzBaseURL.decode_query   s$    
 $*6t666v666r   c                <    t          t          | g|R i |          S )zJoins this URL with another one.  This is just a convenience
        function for calling into :meth:`url_join` and then parsing the
        return value again.
        )	url_parseurl_joinrt   s      r   joinzBaseURL.join   s*    
 $888888999r   c                     t          |           S )zReturns a URL string or bytes depending on the type of the
        information stored.  This is just a convenience function
        for calling :meth:`url_unparse` for this URL.
        )url_unparserI   s    r   rH   zBaseURL.to_url   s    
 4   r   c                   | j         pd}d|v rd| d}| j        }|| d| }d                    t          dt	          | j        pdddd          t	          | j        pdddd          g                    }|r| d	| }|S )
z6Encodes the netloc part to an ASCII safe URL as bytes. :[]Nutf-8strictz/:%@)rZ   r_   ry   filter	url_quoterk   rp   )rJ   rY   r_   rb   s       r   encode_netloczBaseURL.encode_netloc   s    _""99RByBxxd/52w%PPd/52w%PP 
 
  	 2B	r   c           
     l   | j         pd}t          |t                    r|                                }t	          |          }d|v rd| d}| j        }|| d| }d                    t          dt          | j	        pdd          t          | j
        pdd          g                    }|r| d| }|S )z&Decodes the netloc part into a string.r}   r~   r   r   Nz/:%@r   )rR   rU   bytesrV   r   r_   ry   r   rf   rk   rp   )rJ   rR   rY   r_   rb   s        r   decode_netloczBaseURL.decode_netloc   s    yBdE"" 	!;;==D$"99RByBxx'(9(?RHH'(9(?RHH 
 
  	 2B	r   c                :    t          t          |                     S )a*  Returns a :class:`BytesURL` tuple that holds a URI.  This will
        encode all the information in the URL properly to ASCII using the
        rules a web browser would follow.

        It's usually more interesting to directly call :meth:`iri_to_uri` which
        will return a string.
        )rw   
iri_to_urirI   s    r   to_uri_tuplezBaseURL.to_uri_tuple   s     D))***r   c                :    t          t          |                     S )aS  Returns a :class:`URL` tuple that holds a IRI.  This will try
        to decode as much information as possible in the URL without
        losing information similar to how a web browser does it for the
        URL bar.

        It's usually more interesting to directly call :meth:`uri_to_iri` which
        will return a string.
        )rw   
uri_to_irirI   s    r   to_iri_tuplezBaseURL.to_iri_tuple   s     D))***r   N
pathformattuple[str | None, str | None]c                   | j         dk    rdS t          | j                  }| j        pd}|t          j        dk    rd}nd}|dk    r|dd         dk    r?|dd	                                         r#|d	d
         dv r|dd	          d|d
d          }|dd
         dv }ddl}|                    |          }|rN|L|	                    d          
                    dd          }t          |          d	k    r|\  }}n=|d         }d}n2|dk    rddl}|                    |          }nt          d|          |dv rd}||fS )a@  Returns a tuple with the location of the file in the form
        ``(server, location)``.  If the netloc is empty in the URL or
        points to localhost, it's represented as ``None``.

        The `pathformat` by default is autodetection but needs to be set
        when working with URLs of a specific system.  The supported values
        are ``'windows'`` when working with Windows or DOS paths and
        ``'posix'`` when working with posix paths.

        If the URL does not point to a local file, the server and location
        are both represented as ``None``.

        :param pathformat: The expected format of the path component.
                           Currently ``'windows'`` and ``'posix'`` are
                           supported.  Defaults to ``None`` which is
                           autodetect.
        fileNNNntwindowsposixr	   /r<      z|:r~   )z\\\z///r   \r}   zInvalid path format )z	127.0.0.1z::1	localhost)r'   url_unquoter)   r(   osnameisalphantpathnormpathlstripsplitlen	posixpathr^   )rJ   r   r)   rR   windows_sharer   partsr   s           r   get_file_locationzBaseURL.get_file_location   s   ( ;&  :49%%{"dw$&

$
""BQBx34!9#4#4#6#64!9;L;Lqs)00d122h00 !H(;;MMMM??4((D
  D))//a88u::??!&JD$$ 8DD7""%%d++DDA:AABBB444DTzr   tuple[str | None, str]c                ~    | j         | j        v r'| j                            | j                   \  }}}||fS d | j        fS rG   )r3   r(   	partition)rJ   rb   _r(   s       r   ra   zBaseURL._split_netloc=  sE    8t{"""k33DH==OD!V<T[  r   c                    |                                  d         }|sdS | j        |vr|d fS |                    | j                  \  }}}||fS )Nr   r   )ra   r4   r   )rJ   rb   rg   r   rn   s        r   re   zBaseURL._split_authC  sa    !!##A& 	:;d"": $t{ ; ;!X!!r   c                   |                                  d         }|sdS |                    | j                  s/| j        |v r"|                    | j                  \  }}}||fS |d fS |                    | j                  }|dk     r|d fS |d|         }||dz   d          }|                    | j                  r||dd          fS |d fS )Nr	   r   r   )ra   
startswithr5   r4   r   findr6   )rJ   rY   rR   r   r_   idxrests          r   rQ   zBaseURL._split_hostM  s    !!!$ 	:}}T^,, 	{b   "T[ 9 9aTz!t8Oggdn%%77t8O!C%y#'))}??4;'' 	"abb>!Tzr   )r7   r8   r9   r8   r:   r2   r:   r&   )r9   r8   r:   r2   )r:   rO   )r:   r[   )r7   r8   r9   r8   r:   rq   )r:   r2   rG   )r   rO   r:   r   )r:   r   )r:   r   )r,   r-   r.   __doc__	__slots__r/   rC   rK   rN   propertyrR   rZ   r_   rb   rg   rk   rn   rp   ru   ry   rH   r   r   r   r   r   ra   re   rQ   __classcell__)rE   s   @r   r2   r2   :   s          IHHHKKKNNNNNN5 5 5 5 5 5   ' ' ' '
 % % % X%    X 
 
 
 X
 ' ' ' X'    X % % % X%    X % % % X%7 7 7 7: : : :! ! ! !   *   6+ + + +	+ 	+ 	+ 	+ (,< < < < <|! ! ! !" " " "       r   r2   c                  0    e Zd ZdZdZdZdZdZdZdddZ	dS )URLzRepresents a parsed URL.  This behaves like a regular tuple but
    also has some extra attributes that give further insight into the
    URL.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use the ``urllib.parse`` library instead.
    r0   r   r~   r   r   r   rN   charsetr&   errorsr:   BytesURLc           
        t          | j                            d          |                                 | j                            ||          | j                            ||          | j                            ||                    S )zEncodes the URL to a tuple made out of bytes.  The charset is
        only being used for the path, query and fragment.
        r   )r   r'   r   r   r)   r*   r+   rJ   r   r   s      r   r   z
URL.encoder  sw     Kw''  IWf--Jgv..M  &11
 
 	
r   Nr   rN   )r   r&   r   r&   r:   r   )
r,   r-   r.   r   r   r3   r4   r5   r6   r   r0   r   r   r   r   c  sR          I
CFII

 

 

 

 

 

 

r   r   c                  @    e Zd ZdZdZdZdZdZdZdd	Z	ddZ
dddZdS )r   zRepresents a parsed URL in bytes.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use the ``urllib.parse`` library instead.
    r0      @   :   [   ]r:   r&   c                R    |                                                      dd          S )Nr   rN   )rH   rV   rI   s    r   rK   zBytesURL.__str__  s     {{}}##GY777r   r   c                    | j         S )z&Returns the netloc unchanged as bytes.)r(   rI   s    r   r   zBytesURL.encode_netloc  s
    {r   r   rN   r   r   r   c           
        t          | j                            d          |                                 | j                            ||          | j                            ||          | j                            ||                    S )zDecodes the URL to a tuple made out of strings.  The charset is
        only being used for the path, query and fragment.
        r   )r   r'   rV   r   r)   r*   r+   r   s      r   rV   zBytesURL.decode  sw     Kw''  IWf--Jgv..M  &11
 
 	
r   Nr   )r:   r   r   )r   r&   r   r&   r:   r   )r,   r-   r.   r   r   r3   r4   r5   r6   rK   r   rV   r0   r   r   r   r     sz          I
CFII8 8 8 8   

 

 

 

 

 

 

r   r   z&dict[frozenset[int], dict[bytes, int]]_unquote_mapsr}   stringstr | bytesunsafer:   r   c                   t          | t                    r|                     d          } t          t                    r                    d          t          t	                              t          |                     d                    }t	          t          |d                    }	 t                   }n?# t          $ r2 fdt                                          D             x}t          <   Y nw xY w|D ]s}|d d         }||v r9|                    ||                    |                    |dd                     I|                    d           |                    |           tt          |          S )Nr      %r   c                $    i | ]\  }}|v	||S r0   r0   )r   hr   r   s      r   r   z%_unquote_to_bytes.<locals>.<dictcomp>  s+     /
 /
 /
Q1F??Aq???r   r<   %   )rU   r&   r   	frozenset	bytearrayiterr   nextr   KeyError
_hextobyteitemsappendextendr   )r   r   groupsresulthex_to_bytegroupcodes    `     r   _unquote_to_bytesr     s   &# (w''&# (w''y(())F&,,t$$%%FtFC(())F
#F+ 
 
 
/
 /
 /
 /
'--///
 /
 /
 	
mF+++

  ! !RaRy;MM+d+,,,MM%)$$$$MM"MM%    ==s   2C   9C<;C<obj1t.Mapping[str, str] | t.Iterable[tuple[str, str]]r   r&   sortboolkey+t.Callable[[tuple[str, str]], t.Any] | Nonet.Iterator[str]c              #    K   ddl m}  ||           }|rt          ||          }|D ]\  }}|t          |t                    s#t          |                              |          }n|}t          |t                    s#t          |                              |          }	n|}	t          |           dt          |	           V  d S )Nr	   r   )r   =)r   r   sortedrU   r   r&   r   _fast_url_quote_plus)
r   r   r   r   r   iterablekey_str	value_str	key_bytesvalue_bytess
             r   _url_encode_implr     s      100000,<,<S,A,AH -(,,,& W W'5)) 	 G++G44III)U++ 	$i..//88KK#K%i00VV3G3T3TVVVVVVW Wr   valuec                n    	 t          | dd|          S # t          $ r t          | d|          cY S w xY w)Nr   r   )r   r   r   latin1)r   r   )r   rW   )r   r   s     r   rf   rf     sY    C5'(6RRRR C C C5(6BBBBBBCs    44Turlr'   rO   allow_fragmentsc                b   t          j        dt          d           t          |           t	          | t
                    }| d          } d          x}x}}|                      d                    }|dk    ryt                              t          | d|         d	                    rH| |d
z   d         }|rt          fd|D                       r| d|                                         |} }| dd          d          k    rt          |           }	 d          D ].}
|                     |
d          }|dk    rt          |	|          }	/| d|	         | |	d         } } d          |v r d          |vs d          |v r d          |vrt          d          |r/ d          | v r"|                      d          d
          \  } } d          | v r"|                      d          d
          \  } }|rt           nt"          } |||| ||          S )a  Parses a URL from a string into a :class:`URL` tuple.  If the URL
    is lacking a scheme it can be provided as second argument. Otherwise,
    it is ignored.  Optionally fragments can be stripped from the URL
    by setting `allow_fragments` to `False`.

    The inverse of this function is :func:`url_unparse`.

    :param url: the URL to parse.
    :param scheme: the default schema to use if the URL is schemaless.
    :param allow_fragments: if set to `False` a fragment will be removed
                            from the URL.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use ``urllib.parse.urlsplit`` instead.
    zq'werkzeug.urls.url_parse' is deprecated and will be removed in Werkzeug 3.0. Use 'urllib.parse.urlsplit' instead.r<   r=   Nr}   r~   r   rN   )r   r	   c              3  2   K   | ]}| d           vV  dS )
0123456789Nr0   )r   css     r   	<genexpr>zurl_parse.<locals>.<genexpr>
  s0      BB1AAlOO3BBBBBBr   ///?#r   r   zInvalid IPv6 URL#?)r?   r@   rA   r   rU   r&   r   
_scheme_rematchr   anylowerr   minr]   r   r   r   )r   r'   r   is_text_basedr(   r*   r+   ir   delimr   wdelimresult_typer   s                @r   rw   rw     sw   $ M	0	    	S!!AsC((M~2 !"%F%UX3A1uu!!'#bqb')"D"D"DEEu 1q577| 	0sBBBBTBBBBB 	0bqb'--//4CF
2A2w!!D''C5 	+ 	+AXXa^^F{{E6**!E'lCKAcFFf3v!5!5AcFFf3v!5!5/000 -11S66S==		!!C&&!,,Xqvv}}YYqqvvq))
U&4##HK;vvsE8<<<r   r   r   /:r   safet.Callable[[bytes], str]c                z   t          t                    r                    | |          t          |t                    r|                    | |          }t          t	                              t
          z  t          t	          |                    z
  fdt          d          D             dfd}|S )	a  Precompile the translation table for a URL encoding function.

    Unlike :func:`url_quote`, the generated function only takes the
    string to quote.

    :param charset: The charset to encode the result with.
    :param errors: How to handle encoding errors.
    :param safe: An optional sequence of safe characters to never encode.
    :param unsafe: An optional sequence of unsafe characters to always encode.
    c                B    g | ]}|v rt          |          nd |dS )r   r    )chr)r   r   r  s     r   r"   z(_make_fast_url_quote.<locals>.<listcomp>;  s3    FFFaqDyySVVVk!kkkFFFr   r#   r   r   r:   r&   c                F    d                     fd| D                       S )Nr}   c                     g | ]
}|         S r0   r0   )r   r   tables     r   r"   z7_make_fast_url_quote.<locals>.quote.<locals>.<listcomp>>  s    111Qa111r   )ry   )r   r  s    r   r   z#_make_fast_url_quote.<locals>.quote=  s*    ww1111&111222r   r   r   r:   r&   )rU   r&   r   r   r   _always_saferange)r   r   r  r   r   r  s     `  @r   _make_fast_url_quoter  $  s      $ ,{{7F++&# 0w//ioo&&59VCTCT9U9UUDFFFF5::FFFE3 3 3 3 3 3 Lr    +)r  r   c                H    t          |                               dd          S )Nr  r  )_fast_quote_plusrN   )r   s    r   r   r   G  s     F##++C555r   c                   t          j        dt          d           t          | t          t
          t          f          st	          |           } t          | t                    r|                     ||          } t          |t                    r|                    ||          }t          |t                    r|                    ||          }t          t          |                    t          z  t          t          |                    z
  }t                      }t          |           D ]<}||v r|
                    |           |                    t          |                    =t          |                              |          S )a  URL encode a single string with a given encoding.

    :param s: the string to quote.
    :param charset: the charset to be used.
    :param safe: an optional sequence of safe characters.
    :param unsafe: an optional sequence of unsafe characters.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use ``urllib.parse.quote`` instead.

    .. versionadded:: 0.9.2
       The `unsafe` parameter was added.
    zn'werkzeug.urls.url_quote' is deprecated and will be removed in Werkzeug 3.0. Use 'urllib.parse.quote' instead.r<   r=   )r?   r@   rA   rU   r&   r   r   r   r   r  r   r   
_bytetohexrV   )r   r   r   r  r   rY   r!   s          r   r   r   K  sX   ( M	-	    fsE9566 V&# 0w//$ ,{{7F++&# 0w//ioo&&59VCTCT9U9UUD	B&!! ( (4<<IIdOOOOIIj&''''99G$$$r   c                    t          j        dt          d           t          | |||dz   d                              dd          S )aO  URL encode a single string with the given encoding and convert
    whitespace to "+".

    :param s: The string to quote.
    :param charset: The charset to be used.
    :param safe: An optional sequence of safe characters.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use ``urllib.parse.quote_plus`` instead.
    zx'werkzeug.urls.url_quote_plus' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.quote_plus' instead.r<   r=   r  r  )r?   r@   rA   r   rN   )r   r   r   r  s       r   url_quote_plusr  x  sT     M	7	    VWfdSj#>>FFsCPPPr   
componentstuple[str, str, str, str, str]c                   t          j        dt          d           t          |            | \  }}}}}t	          |          } |d          }|s |rb|                     |d                    rD|r%|dd          |d          k    r |d          |z   } |d          |p
 |d          z   |z   }n|r||z  }|r| |d	          z   |z   }|r| |d
          z   |z   }|r| |d          z   |z   }|S )ai  The reverse operation to :meth:`url_parse`.  This accepts arbitrary
    as well as :class:`URL` tuples and returns a URL as a string.

    :param components: the parsed URL as tuple which should be converted
                       into a URL string.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use ``urllib.parse.urlunsplit`` instead.
    zu'werkzeug.urls.url_unparse' is deprecated and will be removed in Werkzeug 3.0. Use 'urllib.parse.urlunsplit' instead.r<   r=   r}   r   Nr	   r   r~   r   r   )r?   r@   rA   r
   r   r   )r  r'   r(   r)   r*   r+   r   r   s           r   r{   r{     sV    M	2	    Z   ,6)FFD%V$$A
!B%%C  & T__QQsVV44  	!D!H#&&1S66D=Dagg11R55)D0	 t $qqvvo# #AAcFFlU" &AAcFFlX%Jr   rN   r   c                    t          j        dt          d           t          | |          }||S |                    ||          S )a  URL decode a single string with a given encoding.  If the charset
    is set to `None` no decoding is performed and raw bytes are
    returned.

    :param s: the string to unquote.
    :param charset: the charset of the query string.  If set to `None`
        no decoding will take place.
    :param errors: the error handling for the charset decoding.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use ``urllib.parse.unquote`` instead.
    zr'werkzeug.urls.url_unquote' is deprecated and will be removed in Werkzeug 3.0. Use 'urllib.parse.unquote' instead.r<   r=   )r?   r@   rA   r   rV   )r   r   r   r   rY   s        r   r   r     sW    $ M	/	    
1f	%	%B	99Wf%%%r   c                    t          j        dt          d           t          | t                    r|                     dd          } n|                     dd          } t          | ||          S )a&  URL decode a single string with the given `charset` and decode "+" to
    whitespace.

    Per default encoding errors are ignored.  If you want a different behavior
    you can set `errors` to ``'replace'`` or ``'strict'``.

    :param s: The string to unquote.
    :param charset: the charset of the query string.  If set to `None`
        no decoding will take place.
    :param errors: The error handling for the `charset` decoding.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use ``urllib.parse.unquote_plus`` instead.
    z|'werkzeug.urls.url_unquote_plus' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.unquote_plus' instead.r<   r=   r  r     +    )r?   r@   rA   rU   r&   rN   r   )r   r   r   s      r   url_unquote_plusr&    sv    " M	9	    !S "IIc3IIdD!!q'6***r   c                   t          j        dt          d           t          | |d                              dd          } |                     d          r5| dd	                                         r| d	d
         dv rd| dd          } t          |           }t          |j	        |d          }t          |j        |d          }t          |j        |d          }t          |j        |                                |||f          S )aF  Sometimes you get an URL by a user that just isn't a real URL because
    it contains unsafe characters like ' ' and so on. This function can fix
    some of the problems in a similar way browsers handle data entered by the
    user:

    >>> url_fix('http://de.wikipedia.org/wiki/Elf (Begriffskl\xe4rung)')
    'http://de.wikipedia.org/wiki/Elf%20(Begriffskl%C3%A4rung)'

    :param s: the string with the URL to fix.
    :param charset: The target charset for the URL if the url was given
        as a string.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0.
    zJ'werkzeug.urls.url_fix' is deprecated and will be removed in Werkzeug 3.0.r<   r=   rN   r   r   zfile://      
   )z:/z|/zfile:///Nz
/%+$!*'(),r  z:&%=+$!*'(),)r?   r@   rA   r   rN   r   r   rw   r   r)   r  r*   r+   r{   r'   r   )r   r   r   r)   qsanchors         r   url_fixr.    s     MT    	7I&&..tS99A 	||I 1QqS6>>#3#3 !B$<8O8Oqu
A,,CSXw\:::D		7	@	@	@BCL'GGGF
C$5$5$7$7r6JKKKr   erW   tuple[str, int]c                d    t          | j        | j        | j                 d          }|| j        fS )zRUsed in :func:`uri_to_iri` after unquoting to re-quote any
    invalid bytes.
    r}   r+  )r   objectstartend)r/  outs     r   _codec_error_url_quoter6    s1     15)
3
3
3C:r   werkzeug.url_quoter   chars t.Callable[[str, str, str], str]c                    d                     d t          |          D                       }t          j        d| dt          j                  dfd
}d|  |_        |S )zCreate a function that unquotes all percent encoded characters except those
    given. This allows working with unquoted characters if possible while not changing
    the meaning of a given part of a URL.
    |c              3  8   K   | ]}t          |          d V  dS )r    N)ord)r   r   s     r   r   z%_make_unquote_part.<locals>.<genexpr>-  s,      >>1#a&&>>>>>>r   z((?:%(?:z))+)r   r&   encodingr   r:   c                   t                              |                     }g }|D ]I}|                    t          |||                     |                    t	          |d                     Jd                    |          S )Nr}   )r   r   r   r   r   ry   )r   r>  r   r   r5  partpatterns         r   _unquote_partialz,_make_unquote_part.<locals>._unquote_partial0  s{    W]]5))** 	( 	(DJJwtXv66777JJtE2''''wws||r   	_unquote_)r   r&   r>  r&   r   r&   r:   r&   )ry   r   recompileIr,   )r   r8  choicesrB  rA  s       @r   _make_unquote_partrH  (  s    
 hh>>u>>>>>Gj1G1112488G      !3D 2 2r   !   r      r+   r*   z&=+#r)   r   userz:@/?#uri$str | tuple[str, str, str, str, str]c                f   t          | t                    r+t          j        dt          d           t          |           } t          | t                    r0t          j        dt          d           |                                 } |t          j        dt          d           nd}|t          j        dt          d           nd	}t          |           }t          |j
        ||          }t          |j        ||          }t          |j        ||          }|j        rt!          |j                  }nd
}d|v rd| d}|j        r| d|j         }|j        r?t'          |j        ||          }|j        r| dt'          |j        ||           }| d| }t          |j        ||||f          S )a  Convert a URI to an IRI. All valid UTF-8 characters are unquoted,
    leaving all reserved and invalid characters quoted. If the URL has
    a domain, it is decoded from Punycode.

    >>> uri_to_iri("http://xn--n3h.net/p%C3%A5th?q=%C3%A8ry%DF")
    'http://\u2603.net/p\xe5th?q=\xe8ry%DF'

    :param uri: The URI to convert.
    :param charset: The encoding to encode unquoted bytes with.
    :param errors: Error handler to use during ``bytes.encode``. By
        default, invalid bytes are left quoted.

    .. versionchanged:: 2.3
        Passing a tuple or bytes, and the ``charset`` and ``errors`` parameters, are
        deprecated and will be removed in Werkzeug 3.0.

    .. versionchanged:: 2.3
        Which characters remain quoted is specific to each part of the URL.

    .. versionchanged:: 0.15
        All reserved and invalid characters remain quoted. Previously,
        only some reserved characters were preserved, and invalid bytes
        were replaced instead of left quoted.

    .. versionadded:: 0.6
    HPassing a tuple is deprecated and will not be supported in Werkzeug 3.0.r<   r=   FPassing bytes is deprecated and will not be supported in Werkzeug 3.0.NJThe 'charset' parameter is deprecated and will be removed in Werkzeug 3.0.r   IThe 'errors' parameter is deprecated and will be removed in Werkzeug 3.0.r7  r}   r~   r   r   r   )rU   tupler?   r@   rA   r   r   rV   r   _unquote_pathr)   _unquote_queryr*   _unquote_fragmentr+   hostnamer   r_   rg   _unquote_userrn   r'   )	rL  r   r   r   r)   r*   r+   r(   rb   s	            r   r   r   H  s   > #u V	
 	
 	
 	

 oo#u T	
 	
 	
 	

 jjll 		
 	
 	
 	
 	
 W	
 	
 	
 	
 	
 &SMMEWf55D5;88E &AAH~ en--
f}}Vz *))UZ))~ $U^Wf==> 	NMM]5>7FKKMMD##6##u|VT5(CDDDr   irisafe_conversionbool | Nonec                   |t          j        dt          d           nd}t          | t                    r+t          j        dt          d           t          |           } t          | t                    r1t          j        dt          d           |                     |          } |t          j        dt          d           nd	}|t          j        d
t          d           |rN	 |                     d          }t          |
                                          dk    r| S n# t          $ r Y nw xY wt          |           }t          |j        d||          }t          |j        d||          }t          |j        d||          }|j        r.|j                            d                              d          }	nd}	d|	v rd|	 d}	|j        r|	 d|j         }	|j        rAt          |j        d          }
|j        rt          |j        d          }|
 d| }
|
 d|	 }	t          |j        |	|||f          S )a   Convert an IRI to a URI. All non-ASCII and unsafe characters are
    quoted. If the URL has a domain, it is encoded to Punycode.

    >>> iri_to_uri('http://\u2603.net/p\xe5th?q=\xe8ry%DF')
    'http://xn--n3h.net/p%C3%A5th?q=%C3%A8ry%DF'

    :param iri: The IRI to convert.
    :param charset: The encoding of the IRI.
    :param errors: Error handler to use during ``bytes.encode``.

    .. versionchanged:: 2.3
        Passing a tuple or bytes, and the ``charset`` and ``errors`` parameters, are
        deprecated and will be removed in Werkzeug 3.0.

    .. versionchanged:: 2.3
        Which characters remain unquoted is specific to each part of the URL.

    .. versionchanged:: 2.3
        The ``safe_conversion`` parameter is deprecated and will be removed in Werkzeug
        2.4.

    .. versionchanged:: 0.15
        All reserved characters remain unquoted. Previously, only some reserved
        characters were left unquoted.

    .. versionchanged:: 0.9.6
       The ``safe_conversion`` parameter was added.

    .. versionadded:: 0.6
    NrQ  r<   r=   r   rO  rP  rR  r   zRThe 'safe_conversion' parameter is deprecated and will be removed in Werkzeug 3.0.r   r	   z%!$&'()*+,/:;=@)r  r>  r   z%!$&'()*+,/:;=?@z%!#$&'()*+,/:;=?@rT   r}   r~   r   r   z%!$&'()*+,;=r+  r   )r?   r@   rA   rU   rS  r   r   rV   r   r   r   rW   r   r   r)   r*   r+   rW  r_   rg   rn   r'   )rY  r   r   rZ  	ascii_irir   r)   r*   r+   r(   rb   pass_quoteds               r   r   r     s   H  		
 	
 	
 	
 	
 #u V	
 	
 	
 	

 oo#u "T	
 	
 	
 	

 jj!!W	
 	
 	
 	
 	
 "		
 	
 	
 	
  
	

7++I 9??$$%%**
 + 	 	 	D	 SMME "3gfUUUD%+$6QWXXXE076  H ~ &&v..55g>>
f}}Vz *))UZ))~ $U^.999> 	+^DDDK**[**D##6##u|VT5(CDDDs   *;D' '
D43D4c                    	 |                      d           t          |                     dd                    dk    r| S n# t          $ r Y nw xY wt	          |           S )a  The URL scheme ``itms-services://`` must contain the ``//`` even though it does
    not have a host component. There may be other invalid schemes as well. Currently,
    responses will always call ``iri_to_uri`` on the redirect ``Location`` header, which
    removes the ``//``. For now, if the IRI only contains ASCII and does not contain
    spaces, pass it on as-is. In Werkzeug 3.0, this should become a
    ``response.process_location`` flag.

    :meta private:
    r   Nr	   )r   r   r   rW   r   )rY  s    r   _invalid_iri_to_urir`     sv    

7 syyq!!""a''J (     c??s   A 
AA&t.AnyStrinclude_empty	separatorrD   type[ds.MultiDict] | Nonerq   c                   t          j        dt          d           |ddlm} |}t          | t                    r-t          |t                    s|                    |pd          }nAt          | t                    r,t          |t                    s|	                    |pd          } |t          |                     |          |||                    S )a  Parse a query string and return it as a :class:`MultiDict`.

    :param s: The query string to parse.
    :param charset: Decode bytes to string with this charset. If not
        given, bytes are returned as-is.
    :param include_empty: Include keys with empty values in the dict.
    :param errors: Error handling behavior when decoding bytes.
    :param separator: Separator character between pairs.
    :param cls: Container to hold result instead of :class:`MultiDict`.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use ``urllib.parse.parse_qs`` instead.

    .. versionchanged:: 2.1
        The ``decode_keys`` parameter was removed.

    .. versionchanged:: 0.5
        In previous versions ";" and "&" could be used for url decoding.
        Now only "&" is supported. If you want to use ";", a different
        ``separator`` can be provided.

    .. versionchanged:: 0.5
        The ``cls`` parameter was added.
    zr'werkzeug.urls.url_decode' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.parse_qs' instead.r<   r=   Nr	   	MultiDictr   )r?   r@   rA   r   rh  rU   r&   rV   r   r   _url_decode_implr   )r   r   rc  r   rd  rD   rh  s          r   rs   rs   5  s    @ M	0	    {------!S 9*Y"<"< 9$$W%788			Au		 9jE&B&B 9$$W%788	3GGI	
 	
  r      &streamt.IO[bytes]limitr[   c                    t          j        dt          d           ddlm}  || ||          }t          ||||          }	|ddlm}
 |
} ||	          S )a  Works like :func:`url_decode` but decodes a stream.  The behavior
    of stream and limit follows functions like
    :func:`~werkzeug.wsgi.make_line_iter`.  The generator of pairs is
    directly fed to the `cls` so you can consume the data while it's
    parsed.

    :param stream: a stream with the encoded querystring
    :param charset: the charset of the query string.  If set to `None`
        no decoding will take place.
    :param include_empty: Set to `False` if you don't want empty values to
                          appear in the dict.
    :param errors: the decoding error behavior.
    :param separator: the pair separator to be used, defaults to ``&``
    :param cls: an optional dict class to use.  If this is not specified
                       or `None` the default :class:`MultiDict` is used.
    :param limit: the content length of the URL data.  Not necessary if
                  a limited stream is provided.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 2.4. Use ``urllib.parse.parse_qs`` instead.

    .. versionchanged:: 2.1
        The ``decode_keys`` and ``return_iterator`` parameters were removed.

    .. versionadded:: 0.8
    zy'werkzeug.urls.url_decode_stream' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.parse_qs' instead.r<   r=   r	   )make_chunk_iterNrg  )r?   r@   rA   wsgiro  ri  r   rh  )rk  r   rc  r   rd  rD   rm  ro  	pair_iterdecoderrh  s              r   url_decode_streamrs  k  s    F M	>	    &%%%%%	599Iy'=&IIG
{------3w<<r   rq  t.Iterable[t.AnyStr]t.Iterator[tuple[str, str]]c              #     K   | D ]q}|st          |          } |d          }||v r|                    |d          \  }}n|s@|} |d          }t          |||          t          |||          fV  rd S )Nr   r	   r}   )r   r   r&  )	rq  r   rc  r   pairr   equalr   r   s	            r   ri  ri    s        
 
 	 &&#D==E1--JC  CAbEEES'622UGV44
 	
 	
 	
 	

 
r   Fc                    t          j        dt          d           t          |d          }|                    t          | |||                    S )aP  URL encode a dict/`MultiDict`.  If a value is `None` it will not appear
    in the result string.  Per default only values are encoded into the target
    charset strings.

    :param obj: the object to encode into a query string.
    :param charset: the charset of the query string.
    :param sort: set to `True` if you want parameters to be sorted by `key`.
    :param separator: the separator to be used for the pairs.
    :param key: an optional function to be used for sorting.  For more details
                check out the :func:`sorted` documentation.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 2.4. Use ``urllib.parse.urlencode`` instead.

    .. versionchanged:: 2.1
        The ``encode_keys`` parameter was removed.

    .. versionchanged:: 0.5
        Added the ``sort``, ``key``, and ``separator`` parameters.
    zs'werkzeug.urls.url_encode' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.urlencode' instead.r<   r=   r   )r?   r@   rA   r   ry   r   )r   r   r   r   rd  s        r   
url_encoderz    sZ    6 M	1	    	7++I>>*3sCCDDDr   t.IO[str] | NoneNonec                   t          j        dt          d           t          |d          }t	          | |||          }||S t          |          D ]1\  }}|r|                    |           |                    |           2dS )a  Like :meth:`url_encode` but writes the results to a stream
    object.  If the stream is `None` a generator over all encoded
    pairs is returned.

    :param obj: the object to encode into a query string.
    :param stream: a stream to write the encoded object into or `None` if
                   an iterator over the encoded pairs should be returned.  In
                   that case the separator argument is ignored.
    :param charset: the charset of the query string.
    :param sort: set to `True` if you want parameters to be sorted by `key`.
    :param separator: the separator to be used for the pairs.
    :param key: an optional function to be used for sorting.  For more details
                check out the :func:`sorted` documentation.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 2.4. Use ``urllib.parse.urlencode`` instead.

    .. versionchanged:: 2.1
        The ``encode_keys`` parameter was removed.

    .. versionadded:: 0.8
    zz'werkzeug.urls.url_encode_stream' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.urlencode' instead.r<   r=   r   N)r?   r@   rA   r   r   	enumeratewrite)	r   rk  r   r   r   rd  genr   chunks	            r   url_encode_streamr    s    < M	?	    	7++I
3s
3
3C~
nn  
U 	$LL###U4r   basec                   t          j        dt          d           t          | t                    rt          |           } t          |t                    rt          |          }t          | |f           t          |           | s|S |s| S t          | |          \  }}}}}t          |||          \  }}	}
}}||k    r|S |	rt          ||	|
||f          S |}	|
dd          d          k    r|
	                     d                    }nj|
s#|	                     d                    }|s|}nE|	                     d                    dd         |
	                     d                    z   }|d          d	          k    r d
          |d<   fd|D             }	 d}t          |          dz
  }||k     rM||          d          k    r-||dz
            d
           d          fvr||dz
  |dz   = n|dz  }||k     Mni d
           d          g}|dd         |k    r|d= |dd         |k     d                              |          }
t          ||	|
||f          S )aq  Join a base URL and a possibly relative URL to form an absolute
    interpretation of the latter.

    :param base: the base URL for the join operation.
    :param url: the URL to join.
    :param allow_fragments: indicates whether fragments should be allowed.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 2.4. Use ``urllib.parse.urljoin`` instead.
    zo'werkzeug.urls.url_join' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.urljoin' instead.r<   r=   )r   Nr	   r   .r}   c                2    g | ]}| d           k    |S )r  r0   )r   segmentr   s     r   r"   zurl_join.<locals>.<listcomp>G  s+    EEEG7aaff3D3D3D3D3Dr   Tz..)r?   r@   rA   rU   rS  r{   r
   r   rw   r   r   ry   )r  r   r   bschemebnetlocbpathbquery	bfragmentr'   r(   r)   r*   r+   segmentsr  nunwanted_markerr   s                    @r   rx   rx     s    M	/	    $ !4  #u #dC[!!!T""A 
 1:o2 2 2.GWeVY -6c7O,T,T)FFD%
 DFFD%BCCCFBQBx11S66::aaff%% A;;qqvv&& 	E;;qqvv&&ss+djj3.@.@@ |qqvvquu FEEExEEEH	MMA!ee{aagg%%(1q5/!!B%%4AQ*Q*QQUQU]+FA	 !ee 	 quuaagg&O
2A2,/
)
)QK 2A2,/
)
) 1S66;;x  DeX>???r   r>  c                X    d t          |           D             }t          |d|          S )Nc                "    g | ]}|d          
|S )r	   r0   )r   xs     r   r"   z_urlencode.<locals>.<listcomp>_  s!    DDD11Q43CQ3C3C3Cr   z!$'()*,/:;?@)r  r>  )r   r   )r*   r>  r   s      r   
_urlencoder  \  s6     ED(//DDDEU(CCCCr   )r}   )r   r   r   r   r:   r   )
r   r   r   r&   r   r   r   r   r:   r   )r   r&   r   r&   r:   r&   )NT)r   r&   r'   rO   r   r   r:   r2   )r   r   r
  r}   )
r   r&   r   r&   r  r   r   r   r:   r  r  )r   r   r   r&   r   r&   r  r   r   r   r:   r&   )r   r   r}   )
r   r&   r   r&   r   r&   r  r&   r:   r&   )r  r   r:   r&   )r   rN   r}   )
r   r   r   r&   r   r&   r   r&   r:   r&   r   )r   r   r   r&   r   r&   r:   r&   )r   )r   r&   r   r&   r:   r&   )r/  rW   r:   r0  )r   r&   r8  r&   r:   r9  r   )rL  rM  r   rO   r   rO   r:   r&   )NNN)
rY  rM  r   rO   r   rO   rZ  r[  r:   r&   )rY  r&   r:   r&   )r   TrN   ra  N)r   rb  r   r&   rc  r   r   r&   rd  r&   rD   re  r:   rq   )r   TrN   rj  NN)rk  rl  r   r&   rc  r   r   r&   rd  r   rD   re  rm  r[   r:   rq   )
rq  rt  r   r&   rc  r   r   r&   r:   ru  )r   FNra  )r   r   r   r&   r   r   r   r   rd  r&   r:   r&   )Nr   FNra  )r   r   rk  r{  r   r&   r   r   r   r   rd  r&   r:   r|  )T)r  rM  r   rM  r   r   r:   r&   )r*   r   r>  r&   r:   r&   )Lr   
__future__r   codecsr   rD  typingtr?   urllib.parser   r   r   r   r   	_internalr
   r   r   r   r   r   TYPE_CHECKINGr}   dsrE  r   _always_safe_charsr   r   r  r   r   r  r  
NamedTupler%   r2   r   r   r   r/   r   r   rf   rw   r  _fast_url_quoter  r   r   r  r{   r   r&  r.  r6  register_errorrH  r   rV   _always_unsaferV  rU  rT  rX  r   r   r`  rs   rs  ri  rz  r  rx   r  r0   r   r   <module>r     so    
 # " " " " "  				 				                        " " " " " " ! ! ! ! ! ! # # # # # # ' ' ' ' ' ' # # # # # # + + + + + +       , , , , , ,? '&&&&&& RZ,--
  y+227;;<<%
   

 EDsDDD
       f f f f fi f f fR	
 
 
 
 
' 
 
 
8
 
 
 
 
w 
 
 
B :Cj8Q Q Q Q Q    >W W W W<C C C C C BF:= := := := :=| 	    > '&((''S=== 6 6 6 6 *% *% *% *% *%\ NPQ Q Q Q Q.% % % %T 	& & & & &> ;D+ + + + +@#L #L #L #L #LL     *,B C C C   2 1t1d1D112299;;&&z>BB ##G^f-DEE""6>E+ABB""6>G+CDD
 ZE ZE ZE ZE ZE~ #'	xE xE xE xE xEv   . %)3 3 3 3 3p %)4 4 4 4 4n
 
 
 
. 7;"E "E "E "E "EN  $7;, , , , ,d !N@ N@ N@ N@ N@d OVD D D D D D Dr   