
    2BfD                        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e	dej                  e	   d	efd
Z	 	 dde	dej                  e	   dej                  ej                  e	ej                  e   f      dej                  ej                  e	      d	e	f
dZ	 	 	 dde	de	dej                  e	   dej                  e	   dej                  e   d	e	fdZy)    N   )_encode_idna)SecurityError)
uri_to_iri)	url_quotehostnametrusted_listreturnc                 6   | syt        |t              r|g}dt        dt        fd}	  ||       }|D ]F  }|j	                  d      r|dd }d}nd}	  ||      }||k(  r y|s1|j                  d	|z         sF y y# t        $ r Y yw xY w# t        $ r Y  yw xY w)
zCheck if a host matches a list of trusted names.

    :param hostname: The name to check.
    :param trusted_list: A list of valid names to match. If a name
        starts with a dot it will match all subdomains.

    .. versionadded:: 0.9
    Fr   r
   c                 J    d| v r| j                  dd      d   } t        |       S )N:   r   )rsplitr   )r   s    U/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/werkzeug/sansio/utils.py
_normalizez#host_is_trusted.<locals>._normalize   s)    (?sA.q1HH%%    .r   NT   .)
isinstancestrbytesUnicodeError
startswithendswith)r   r	   r   hostname_bytesrefsuffix_match	ref_bytess          r   host_is_trustedr   	   s     ,$$~&S &U &#H-  >>#ab'CL L	"3I &N33D94DE!$ +    		s#   A< B<	BB	BBschemehost_headerservertrusted_hostsc                     d}||}n||d   }|d   
| d|d    }| dv r|j                  d      r|dd }n| d	v r|j                  d
      r|dd }|t        ||      st        d|d      |S )a$  Return the host for the given parameters.

    This first checks the ``host_header``. If it's not present, then
    ``server`` is used. The host will only contain the port if it is
    different than the standard port for the protocol.

    Optionally, verify that the host is trusted using
    :func:`host_is_trusted` and raise a
    :exc:`~werkzeug.exceptions.SecurityError` if it is not.

    :param scheme: The protocol the request used, like ``"https"``.
    :param host_header: The ``Host`` header value.
    :param server: Address of the server. ``(host, port)``, or
        ``(path, None)`` for unix sockets.
    :param trusted_hosts: A list of trusted host names.

    :return: Host, with port if necessary.
    :raise ~werkzeug.exceptions.SecurityError: If the host is not
        trusted.
     Nr   r   r   >   wshttpz:80>   wsshttpsz:443zHost z is not trusted.)r   r   r   )r    r!   r"   r#   hosts        r   get_hostr-   8   s    4 D		ay!9 V1VAYK(DDMM%$8CRy	#	#f(=CRy t]3%x/? @AAKr   r,   	root_pathpathquery_stringc                    | d|g}|+|j                  d       t        dj                  |            S |j                  t        |j	                  d                   |j                  d       |t        dj                  |            S |j                  t        |j                  d                   |r-|j                  d       |j                  t        |d             t        dj                  |            S )a  Recreate the URL for a request. If an optional part isn't
    provided, it and subsequent parts are not included in the URL.

    The URL is an IRI, not a URI, so it may contain Unicode characters.
    Use :func:`~werkzeug.urls.iri_to_uri` to convert it to ASCII.

    :param scheme: The protocol the request used, like ``"https"``.
    :param host: The host the request was made to. See :func:`get_host`.
    :param root_path: Prefix that the application is mounted under. This
        is prepended to ``path``.
    :param path: The path part of the URL after ``root_path``.
    :param query_string: The portion of the URL after the "?".
    z:///r%   ?z:&%=+$!*'(),)safe)appendr   joinr   rstriplstrip)r    r,   r.   r/   r0   urls         r   get_current_urlr:   h   s    ( 5$
C

3"''#,''JJy))#./0JJsO|"''#,''JJyS)*+

3

9\?@bggcl##r   )NN)NNN)typingt	_internalr   
exceptionsr   urlsr   r   r   Iterableboolr   OptionalTupleintr-   r   r:    r   r   <module>rF      s    $ &  ,c ,C ,T ,d 9=15	--C- JJqwwsAJJsO345- ::ajjo.	-
 	-f "& &*&$&$
&$ zz#&$ **S/	&$
 **U#&$ 	&$r   