HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.60.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 5 05:00:59 EST 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //var/opt/nydus/ops/asn1crypto/__pycache__/_iri.cpython-39.pyc
a

�,�h"�@s�dZddlmZmZmZmZddlmZddlZddl	Z	ddl
Z
ddlmZddl
mZmZmZmZmZe
jdkr�dd	lmZmZdd
lmZmZnddlmZmZmZmZdd
d�Zdd�Zdd�Ze� de�ddd�Z!ddd�Z"dS)z�
Functions to convert unicode IRIs into ASCII byte string URIs and back. Exports
the following items:

 - iri_to_uri()
 - uri_to_iri()
�)�unicode_literals�division�absolute_import�print_function)�idnaN�)�unwrap)�byte_cls�str_cls�	type_name�
bytes_to_list�	int_types)�)�urlsplit�
urlunsplit)�quote�unquote)r�unquote_to_bytesrrFcCs$t|t�sttdt|����d}tjdkr�|�d�s�|�d�s�d}t�	d|�}|rp|�
d�}d|t|�d�}t|�}|r�||dd�}t
|dd	��}nt|�}|dur�t
|j�}|j}|dur�|�d
�}t
|jdd�}t
|jdd�}|j}	|	du�r
t|	��d
�}	d}
|du�r:|
|7}
|�r2|
d|7}
|
d7}
|du�rL|
|7}
|	du�r�|dk�of|	dk}|dk�ox|	dk}|�r�|�s�|�s�|
d|	7}
t
|jdd�}
t
|jdd�}t
|jdd�}|�r�|du�r�|du�r�|
dk�r�d}
|
du�r�d}
t||
|
||f�}t|t��r |�d�}|S)z�
    Encodes a unicode IRI into an ASCII byte string URI

    :param value:
        A unicode string of an IRI

    :param normalize:
        A bool that controls URI normalization

    :return:
        A byte string of the ASCII-encoded URI
    z@
            value must be a unicode string, not %s
            N)��zhttp://zhttps://z	^[^:]*://rr���rz!$&'()*+,;=��safe�ascii��:�@shttps80shttpss443z/!$&'()*+,;=@:z/?!$&'()*+,;=@:�/��latin1)�
isinstancer
�	TypeErrorrr�sys�version_info�
startswith�re�match�group�lenr�	_urlquote�scheme�hostname�encode�username�password�port�path�query�fragmentr)�value�	normalizer*�real_prefixZprefix_match�parsedr+r-r.r/�netlocZdefault_httpZ
default_httpsr0r1r2�output�r9�@/opt/nydus/tmp/pip-target-wkfpz8uv/lib/python/asn1crypto/_iri.py�
iri_to_uri%sf
�






$

r;cCs(t|t�sttdt|����t|�}|j}|dur<|�d�}t|j	ddgd�}t|j
ddgd�}|j}|rt|�d�}|j}|r�t|t
�s�|�d�}d}|dur�||7}|r�|d|7}|d7}|dur�||7}|dur�|dt|�7}t|jd	gd
d�}t|jdd
gd
d�}	t|j�}
t||||	|
f�S)z�
    Converts an ASCII URI byte string into a unicode IRI

    :param value:
        An ASCII-encoded byte string of the URI

    :return:
        A unicode string of the IRI
    z=
            value must be a byte string, not %s
            Nr�:�@)�remaprr�/T)r>�preserve�&�=)r r	r!rrrr*�decode�_urlunquoter-r.r+r/r
r
r0r1r2r)r3r6r*r-r.r+r/r7r0r1r2r9r9r:�
uri_to_irixs>
�



rEcCs4t|j|j|j��}dd�|D�}d�|�|jfS)a>
    Error handler for decoding UTF-8 parts of a URI into an IRI. Leaves byte
    sequences encoded in %XX format, but as part of a unicode string.

    :param exc:
        The UnicodeDecodeError exception

    :return:
        A 2-element tuple of (replacement unicode string, integer index to
        resume at)
    cSsg|]}d|�qS)�%%%02xr9)�.0�numr9r9r:�
<listcomp>�rz,_iri_utf8_errors_handler.<locals>.<listcomp>r)r�object�start�end�join)�excZ
bytes_as_ints�replacementsr9r9r:�_iri_utf8_errors_handler�s
rP�iriutf8rcs�|dus|dkrdSg�t�d|�rX�fdd�}t�d||�}�fdd�}t�d||�}t|�d	���d	�d
�}t|t�s�|�d�}t��dkr��fd
d�}t�d||�}|S)a
    Quotes a unicode string for use in a URL

    :param string:
        A unicode string

    :param safe:
        A unicode string of character to not encode

    :return:
        None (if string is None) or an ASCII byte string of the quoted string
    Nrz%[0-9a-fA-F]{2}cs@t|�d��}|�dd�}t��D]}|�|dt|��}q"|S)Nr�utf-8rQrF)rr'rC�list�replace�ord)r&�byte_stringZunicode_stringZ	safe_charrr9r:�
_try_unescape�s
z _urlquote.<locals>._try_unescapez(?:%[0-9a-fA-F]{2})+cs��|�d��d��dS)Nrr�)�appendr'r,)r&��escapesr9r:�_extract_escape�sz"_urlquote.<locals>._extract_escaperRrrrcs
��d�S)Nr)�pop)�_rZr9r:�_return_escape�sz!_urlquote.<locals>._return_escapes%00)r%�search�sub�urlquoter,r r	r()�stringrrWr\r8r_r9)r[rr:r)�s

r)c	Cs�|dur|S|dkrdS|r\gd�}i}|D].}|�d�}|||<|�|�d�|�d��}q,t|�}|r�|D]$}|�|�d�dt|��d��}ql|�dd	�}|r�|��D]\}}|�||�}q�|S)
a
    Unquotes a URI portion from a byte string into unicode using UTF-8

    :param byte_string:
        A byte string of the data to unquote

    :param remap:
        A list of characters (as unicode) that should be re-mapped to a
        %XX encoding. This is used when characters are not valid in part of a
        URL.

    :param preserve:
        A bool - indicates that the chars to be remapped if they occur in
        non-hex form, should be preserved. E.g. / for URL path.

    :return:
        A unicode string
    Nrr)�����rrrFrRrQ)r]rTr,rrUrC�items)	rVr>r@rOZpreserve_unmap�char�replacementr8�originalr9r9r:rD�s(
"rD)F)r)NN)#�__doc__�
__future__rrrr�	encodingsr�codecsr%r"�_errorsr�_typesr	r
rrr
r#�urlparserr�urllibrrbrr�urllib.parser;rErP�register_errorr)rDr9r9r9r:�<module>s"

S4
4