o
    Ù­j
  ã                   @  s”   d dl mZ d dlmZ d dlmZ d dlZd dlmZm	Z	m
Z
mZ d dlZddlmZ dZddd„Zddd„Ze d¡Ze d¡Zdddd„ZdS )é    )Úannotations)ÚCallable)ÚsuppressN)ÚquoteÚunquoteÚurlparseÚ
urlunparseé   )Ú	_punycode)zhttp:zhttps:zmailto:ÚurlÚstrÚreturnc                 C  sp   t j| dd�}|jr0|jr|jtv r0ttƒ� |jt 	|j¡d�}W d  ƒ n1 s+w   Y  t  
t  |¡¡S )zvNormalize destination URLs in links

    ::

        [label]:   destination   'title'
                ^^^^^^^^^^^
    T©Úslashes_denote_host©ÚhostnameN)ÚmdurlÚparser   ÚprotocolÚRECODE_HOSTNAME_FORr   Ú	ExceptionÚ_replacer
   Úto_asciiÚencodeÚformat©r   Úparsed© r   ú]/var/www/html/CropPilot/venv/lib/python3.10/site-packages/markdown_it/common/normalize_url.pyÚnormalizeLink   s   ÿ

ÿr   c                 C  sx   t j| dd�}|jr0|jr|jtv r0ttƒ� |jt 	|j¡d�}W d  ƒ n1 s+w   Y  t  
t  |¡t jd ¡S )zSNormalize autolink content

    ::

        <destination>
         ~~~~~~~~~~~
    Tr   r   Nú%)r   r   r   r   r   r   r   r   r
   Ú
to_unicodeÚdecoder   ÚDECODE_DEFAULT_CHARSr   r   r   r   ÚnormalizeLinkText(   s   ÿ

ÿr$   z!^(vbscript|javascript|file|data):z!^data:image\/(gif|png|jpeg|webp);Ú	validatorúCallable[[str], bool] | NoneÚboolc                 C  s8   |dur|| ƒS |   ¡  ¡ } t | ¡rtt | ¡ƒS dS )a  Validate URL link is allowed in output.

    This validator can prohibit more than really needed to prevent XSS.
    It's a tradeoff to keep code simple and to be secure by default.

    Note: url should be normalized at this point, and existing entities decoded.
    NT)ÚstripÚlowerÚBAD_PROTO_REÚsearchr'   ÚGOOD_DATA_RE)r   r%   r   r   r   ÚvalidateLinkF   s   r-   )r   r   r   r   )N)r   r   r%   r&   r   r'   )Ú
__future__r   Úcollections.abcr   Ú
contextlibr   ÚreÚurllib.parser   r   r   r   r   Ú r
   r   r   r$   Úcompiler*   r,   r-   r   r   r   r   Ú<module>   s    



