HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/validators/__pycache__/url.cpython-310.pyc
o

we��@sdZddlmZddlZddlmZmZddlmZddlm	Z	edd	��Z
ed
d��Zedd
��Zde
fdd�Zde
defdd�Zde
fdd�Zde
dedededededefdd�Zde
de
de
fd d!�Ze	d"d"d#d"d"d"d$�de
dedededededefd%d&��ZdS)'zURL.�)�	lru_cacheN)�unquote�urlsplit�)�hostname)�	validatorcC�t�dtj�S)Nz�(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*$|^([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*$)��re�compile�
IGNORECASE�r
r
�G/home/arjun/projects/env/lib/python3.10/site-packages/validators/url.py�_username_regex
s�rcCr)Nzp^[\/a-zA-Z0-9\-\.\_\~\!\$\&\'\(\)\*\+\,\;\=\:\@\%\U0001F600-\U0001F64F\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$r	r
r
r
r�_path_regexs�rcCr)Nz&?(\w+=?[^\s&]*)r	r
r
r
r�_query_regex%sr�valuecCs|r|dvSdS)zValidate scheme.>	�ftp�git�ssh�ftps�http�rtsp�sftp�https�telnetFr
)rr
r
r�_validate_scheme*s
���r�skip_ipv6_addrcCs|p|�d�dkp|�d�S)zConfirm skip IPv6 check.�:��[)�count�
startswith)rrr
r
r�_confirm_ipv6_skip4sr#csp|sdS|�d�}dkrt��t|��S|dkrt��|�S|�dd�\}�t��|�o7t�fdd�dD��S)z Validate authentication segment.Trrc3��|]}|�vVqdS�Nr
��.0�
char_to_avoid��passwordr
r�	<genexpr>Ds�
�z)_validate_auth_segment.<locals>.<genexpr>)�/�?�#�@)r!r�matchr�rsplit�all)r�colon_count�usernamer
r)r�_validate_auth_segment9s�r5�skip_ipv4_addr�
may_have_port�simple_host�rfc_1034�rfc_2782c		Cs�|r	|�d�dkrdS|�d�dkr3tt||�sd|vr|n	|�d��ddd�t||�|||||d�S|�dd�\}}tt||�sEd|vrG|n	|�d��ddd�t||�|||||d�o_t|�S)	zValidate netloc.r/rFz]:r �]�)rr6r7�maybe_simpler9r:)r!rr#�lstrip�replacer1r5)	rrr6r7r8r9r:�
basic_auth�hostr
r
r�_validate_netlocIs@
������
�rB�path�query�fragmentcsnd}|r|tt��|��M}|r|tt��|��M}�r5��d�r&��d�n��|t�fdd�dD��M}|S)z"Validate path query and fragments.Tr,c3r$r%r
r&�rEr
rr+xs�z&_validate_optionals.<locals>.<genexpr>)r,r-)�boolrr0rr"r>r2)rCrDrE�optional_segmentsr
rFr�_validate_optionalsosrIFT)rr6r7r8r9r:cCsh|rt�d|�r
dSzt|�\}}}	}
}Wn
tyYdSwt|�o3t|||||||�o3t|	|
|�S)a;Return whether or not given value is a valid URL.

    This validator was inspired from [URL validator of dperini][1].
    The following diagram is from [urlly][2].

            foo://admin:hunter1@example.com:8042/over/there?name=ferret#nose
            \_/   \___/ \_____/ \_________/ \__/\_________/ \_________/ \__/
             |      |       |       |        |       |          |         |
          scheme username password hostname port    path      query    fragment

    [1]: https://gist.github.com/dperini/729294
    [2]: https://github.com/treeform/urlly

    Examples:
        >>> url('http://duck.com')
        # Output: True
        >>> url('ftp://foobar.dk')
        # Output: True
        >>> url('http://10.0.0.1')
        # Output: True
        >>> url('http://example.com/">user@example.com')
        # Output: ValidationError(func=url, ...)

    Args:
        value:
            URL string to validate.
        skip_ipv6_addr:
            When URL string cannot contain an IPv6 address.
        skip_ipv4_addr:
            When URL string cannot contain an IPv4 address.
        may_have_port:
            URL string may contain port number.
        simple_host:
            URL string maybe only hyphens and alpha-numerals.
        rfc_1034:
            Allow trailing dot in domain/host name.
            Ref: [RFC 1034](https://www.rfc-editor.org/rfc/rfc1034).
        rfc_2782:
            Domain/Host name is of type service record.
            Ref: [RFC 2782](https://www.rfc-editor.org/rfc/rfc2782).

    Returns:
        (Literal[True]):
            If `value` is a valid slug.
        (ValidationError):
            If `value` is an invalid slug.

    Note:
        - *In version 0.11.3*:
            - Added support for URLs containing localhost.
        - *In version 0.11.0*:
            - Made the regular expression case insensitive.
        - *In version 0.10.3*:
            - Added a `public` parameter.
        - *In version 0.10.2*:
            - Added support for various exotic URLs.
            - Fixed various false positives.

    > *New in version 0.2.0*.
    z\sF)r
�searchr�
ValueErrorrrBrI)rrr6r7r8r9r:�scheme�netlocrCrDrEr
r
r�url|s(H���

�rN)�__doc__�	functoolsrr
�urllib.parserrr�utilsrrrr�strrrGr#r5rBrIrNr
r
r
r�<module>sj




������
�&
�������	�