
    i5                    J   S SK Jr  S SKrS SKrS SKJr  SSKJr  SSK	J
r
  SSKJr  SSKJr  \R                  " S	\R                   \R"                  -  \R$                  -  S
9r S     SS jjr  S         SS jjr   S           SS jjr  S     SS jjrg)    )annotationsN)quote   )
_plain_int)SecurityError)parse_set_header)
uri_to_iriz
    (
        [a-z0-9.-]+  # domain or ipv4
    |
        \[[a-f0-9]*:[a-f0-9.:]+]  # ipv6
    )
    (?::[0-9]+)?  # optional port
    )flagsc                   U (       d  g[         R                  U 5      c  gU R                  S5      S   n U(       d  g[        U[        5      (       a  U/nU H  nUR                  S5      (       a  USS nSnOSn UR                  S5      S   R                  S5      R                  S	5      nX :X  d$  U(       d  Md  U R                  SU 35      (       d  M    g   g! [         a       gf = f)
a  Perform some checks on a ``Host`` header ``host:port``. The host must be
made up of valid characters, but this does not check validity beyond that.
If a list of trusted domains is given, the domain must match one.

:param hostname: The ``Host`` header ``host:port`` to check.
:param trusted_list: A list of trusted domains to match. These should
    already be IDNA encoded, but will be encoded if needed. The port is
    ignored for this check. If a name starts with a dot it will match as a
    suffix, accepting all subdomains. If empty or ``None``, all domains are
    allowed.

.. versionchanged:: 3.2
    The value's characters are validated.

.. versionchanged:: 3.2
    ``trusted_list`` defaults to ``None``.

.. versionadded:: 0.9
FN:r   T.   idnaascii)
_host_re	fullmatch	partition
isinstancestr
startswithencodedecodeUnicodeEncodeErrorendswith)hostnametrusted_listrefsuffix_matchs       @/app/.venv/lib/python3.13/site-packages/werkzeug/sansio/utils.pyhost_is_trustedr       s    , (#+!!#&q)H,$$$~>>#ab'CL L	--$Q'..v6==gFC ?||0A0AAcU)0L0L   " 		s   :2C
C('C(c                   Ub  UnO/Ub+  US   b%  US   nSU;   a  US   S:w  a  SU S3nU SUS    3nOgU S;   a  UR                  S5      nOU S	;   a  UR                  S
5      n[        XC5      (       d  U(       a  [        SU< S35      egU$ )aP  Get and validate a request's ``host:port`` based on the given values.

The ``Host`` header sent by the client is preferred. Otherwise, the server's
configured address is used. The port is omitted if it matches the standard
HTTP or HTTPS ports.

The value is passed through :func:`host_is_trusted`. The host must be made
up of valid characters, but this does not check validity beyond that. If a
list of trusted domains is given, the domain must match one.

If the host header is not available, such as for HTTP/0.9 and 1.0, or it has
invalid characters, the empty string is returned. Subdomain and host
routing, and external URL building, will not work in these cases.

:param scheme: The protocol of the request. Used to omit the standard ports
    80 and 443.
:param host_header: The ``Host`` header value.
:param server: The server's configured address ``(host, port)``. The server
    may be using a Unix socket and give ``(path, None)``; this is ignored as
    it would not produce a useful host value.
:param trusted_hosts: A list of trusted domains to match. These should
    already be IDNA encoded, but will be encoded if needed. The port is
    ignored for this check. If a name starts with a dot it will match as a
    suffix, accepting all subdomains. If empty or ``None``, all domains are
    allowed.

:return: Host, with port if necessary.
:raise .SecurityError: If the host is not trusted.

.. versionchanged:: 3.1.8
    The empty string is again returned if no host header value is available,
    or if the characters are invalid.

.. versionchanged:: 3.1.7
    The characters of the host value are validated. The empty string is no
    longer allowed if no header value is available.

.. versionchanged:: 3.2
    When using the server address, Unix sockets are ignored.

.. versionchanged:: 3.1.3
    If ``SERVER_NAME`` is IPv6, it is wrapped in ``[]``.
r   r   r   [] >   wshttpz:80>   wsshttpsz:443zHost z is not trusted.)removesuffixr    r   )schemehost_headerservertrusted_hostshosts        r   get_hostr/   O   s    b 		q	 5ay $;47c>tfA;Dq$   '	#	#  (4//%x/? @AA K    c                   U SU/nUc+  UR                  S5        [        SR                  U5      5      $ UR                  [        UR	                  S5      SS95        UR                  S5        Uc  [        SR                  U5      5      $ UR                  [        UR                  S5      SS95        U(       a*  UR                  S5        UR                  [        USS95        [        SR                  U5      5      $ )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?z!$&'()*+,/:;=?@%)appendr	   joinr   rstriplstrip)r*   r.   	root_pathpathquery_stringurls         r   get_current_urlr=      s    ( 5$
C

3"''#,'' JJuY%%c*1BCDJJsO|"''#,''JJuT[[%,=>?

3

5,>?@bggcl##r0   c                z    Ub  S[        U5      ;   d  U c  g [        S[        U 5      5      $ ! [         a     gf = f)a  Return the ``Content-Length`` header value as an int. If the header is not given
or the ``Transfer-Encoding`` header is ``chunked``, ``None`` is returned to indicate
a streaming request. If the value is not an integer, or negative, 0 is returned.

:param http_content_length: The Content-Length HTTP header.
:param http_transfer_encoding: The Transfer-Encoding HTTP header.

.. versionadded:: 2.2
Nchunkedr   )r   maxr   
ValueError)http_content_lengthhttp_transfer_encodings     r   get_content_lengthrD      sL     	*)*@AA		$1j!4566 s   - 
::)N)r   
str | Noner   t.Collection[str] | Nonereturnbool)NN)
r*   r   r+   rE   r,   ztuple[str, int | None] | Noner-   rF   rG   r   )NNN)r*   r   r.   r   r9   rE   r:   rE   r;   zbytes | NonerG   r   )rB   rE   rC   rE   rG   z
int | None)
__future__r   retypingturllib.parser   	_internalr   
exceptionsr   r&   r   urlsr	   compileASCII
IGNORECASEVERBOSEr   r    r/   r=   rD    r0   r   <module>rV      s"   " 	   " & # :: ((R]]
"RZZ
/
 DH33(@3	3r -1.2	MMM *M ,	M
 	Mf !!%($($
($ ($ 	($
 ($ 	($X '+)-#& r0   