Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/werkzeug/sansio/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/werkzeug/sansio/__pycache__/utils.cpython-312.pyc

�

'ٜg����ddlmZddlZddlmZddlmZddlm	Z	ddl
mZdd�Z		d
									dd	�Z
			d											dd
�Z		d
					dd�Zy)�)�annotationsN)�quote�)�
_plain_int)�
SecurityError)�
uri_to_iric��|sy	|jd�djd�jd�}t	|t
�r|g}|D]n}|j
d�r|dd}d	}nd}	|jd�djd�jd�}||k(s|s�Y|jd|���s�ny	y#t$rYywxYw#t$rYywxYw)
z�Check 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
    F�:r�idna�ascii�.�NT)�	partition�encode�decode�UnicodeEncodeError�
isinstance�str�
startswith�endswith)�hostname�trusted_list�ref�suffix_matchs    �@/usr/local/lib/python3.12/site-packages/werkzeug/sansio/utils.py�host_is_trustedrs�������%�%�c�*�1�-�4�4�V�<�C�C�G�L���,��$�$�~�����>�>�#���a�b�'�C��L� �L�	��-�-��$�Q�'�.�.�v�6�=�=�g�F�C��(�?�|��0A�0A�A�c�U�)�0L�����+�����"�	��	�s#�2B>�+2C
�>	C
�	C
�
	C�Cc��d}|�|}n(|�&|d}d|vr|ddk7rd|�d�}|d�
|�d|d��}|dvr|jd	�r|dd
}n|dvr|jd�r|dd
}|�t||�std|�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.

    .. versionchanged:: 3.1.3
        If ``SERVER_NAME`` is IPv6, it is wrapped in ``[]``.
    �Nrr
�[�]r>�ws�httpz:80���>�wss�httpsz:443���zHost z is not trusted.)rrr)�scheme�host_header�server�
trusted_hosts�hosts     r�get_hostr,1s���:�D�����	�	��a�y���$�;�4��7�c�>��t�f�A�;�D��!�9� ��V�1�V�A�Y�K�(�D�
���D�M�M�%�$8��C�R�y��	�#�	#��
�
�f�(=��C�R�y��� ��t�]�3��%��x�/?� @�A�A��K�c��|d|g}|�+|jd�tdj|��S|jt|j	d�d���|jd�|�tdj|��S|jt|jd�d���|r-|jd�|jt|d���tdj|��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://�/rz!$&'()*+,/:;=@%)�safe�?z!$&'()*+,/:;=?@%)�appendr�joinr�rstrip�lstrip)r'r+�	root_path�path�query_string�urls      r�get_current_urlr:is���(�5�$�
�C����
�
�3���"�'�'�#�,�'�'��J�J�u�Y�%�%�c�*�1B�C�D��J�J�s�O��|��"�'�'�#�,�'�'��J�J�u�T�[�[��%�,=�>�?���
�
�3���
�
�5��,>�?�@��b�g�g�c�l�#�#r-c�\�|dk(s|�y	tdt|��S#t$rYywxYw)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
    �chunkedNr)�maxr�
ValueError)�http_content_length�http_transfer_encodings  r�get_content_lengthrA�s?����*�.A�.I����1�j�!4�5�6�6������s��	+�+)r�
str | Nonerzt.Iterable[str]�return�bool)NN)
r'rr(rBr)ztuple[str, int | None] | Noner*zt.Iterable[str] | NonerCr)NNN)r'rr+rr6rBr7rBr8zbytes | NonerCr)r?rBr@rBrCz
int | None)�
__future__r�typing�t�urllib.parser�	_internalr�
exceptionsr�urlsrrr,r:rA�r-r�<module>rMs���"���"�&��#�R-1�,0�	5��5��5�
*�5�*�	5�
	�5�v!��!%�($��($�

�($��($��	($�
�($�	�
($�X'+�)-��#��&���r-

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists