
    )i
                        S SK Jr  S SKJr  S SKJr  S SKrS SKJrJ	r	J
r
Jr  S SKrSSKJr  SrSS	 jrSS
 jr\R$                  " S5      r\R$                  " S5      rSSS jjrg)    )annotations)Callable)suppressN)quoteunquoteurlparse
urlunparse   )	_punycode)zhttp:zhttps:zmailto:c                   [         R                  " U SS9nUR                  (       aj  UR                  (       a  UR                  [        ;   aE  [        [        5         UR                  [        R                  " UR                  5      S9nSSS5        [         R                  " [         R                  " U5      5      $ ! , (       d  f       N8= f)zfNormalize destination URLs in links

::

    [label]:   destination   'title'
            ^^^^^^^^^^^
Tslashes_denote_hosthostnameN)mdurlparser   protocolRECODE_HOSTNAME_FORr   	Exception_replacer   to_asciiencodeformaturlparseds     `/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/markdown_it/common/normalize_url.pynormalizeLinkr      s     [[$7F OOv2EEi __i.@.@.Q_RF ! <<V,-- ! s   .B;;
C	c                   [         R                  " U SS9nUR                  (       aj  UR                  (       a  UR                  [        ;   aE  [        [        5         UR                  [        R                  " UR                  5      S9nSSS5        [         R                  " [         R                  " U5      [         R                  S-   5      $ ! , (       d  f       NJ= f)zCNormalize autolink content

::

    <destination>
     ~~~~~~~~~~~
Tr   r   N%)r   r   r   r   r   r   r   r   r   
to_unicodedecoder   DECODE_DEFAULT_CHARSr   s     r   normalizeLinkTextr$   (   s     [[$7F OOv2EEi __i.B.B6??.S_TF ! <<V,e.H.H3.NOO	 ! s   .C
Cz!^(vbscript|javascript|file|data):z!^data:image\/(gif|png|jpeg|webp);c                    Ub  U" U 5      $ U R                  5       R                  5       n [        R                  U 5      (       a  [	        [
        R                  U 5      5      $ S$ )zValidate 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.
T)striplowerBAD_PROTO_REsearchboolGOOD_DATA_RE)r   	validators     r   validateLinkr-   F   sS     ~
))+


C-9-@-@-E-E4##C()O4O    )r   strreturnr/   )N)r   r/   r,   zCallable[[str], bool] | Noner0   r*   )
__future__r   collections.abcr   
contextlibr   reurllib.parser   r   r   r	   r    r   r   r   r$   compiler(   r+   r-    r.   r   <module>r9      sT    " $  	 = =  4 .2P4 zz>?zz>?Pr.   