
    gG
                        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)CallableN)quoteunquoteurlparse
urlunparse   )	_punycode)zhttp:zhttps:zmailto:c                h   [         R                  " U SS9nUR                  (       aS  UR                  (       a  UR                  [        ;   a.   UR                  [        R                  " UR                  5      S9n[         R                  " [         R                  " U5      5      $ ! [         a     N6f = f)zfNormalize destination URLs in links

::

    [label]:   destination   'title'
            ^^^^^^^^^^^
Tslashes_denote_hosthostname)mdurlparser   protocolRECODE_HOSTNAME_FOR_replacer
   to_ascii	Exceptionencodeformaturlparseds     @lib/python3.13/site-packages/markdown_it/common/normalize_url.pynormalizeLinkr      s     [[$7F &//5H"H)2D2DV__2UV <<V,--  s   -B$ $
B10B1c                   [         R                  " U SS9nUR                  (       aS  UR                  (       a  UR                  [        ;   a.   UR                  [        R                  " UR                  5      S9n[         R                  " [         R                  " U5      [         R                  S-   5      $ ! [         a     NHf = f)zCNormalize autolink content

::

    <destination>
     ~~~~~~~~~~~
Tr   r   %)r   r   r   r   r   r   r
   
to_unicoder   decoder   DECODE_DEFAULT_CHARSr   s     r   normalizeLinkTextr#   (   s     [[$7F &//5H"H)2F2Fv2WX
 <<V,e.H.H3.NOO	  s   -B6 6
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,   G   sS     ~
))+


C-9-@-@-E-E4##C()O4O    )r   strreturnr.   )N)r   r.   r+   zCallable | Noner/   r)   )
__future__r   collections.abcr   reurllib.parser   r   r   r   r    r
   r   r   r#   compiler'   r*   r,    r-   r   <module>r7      sQ    " $ 	 = =  4 .4P6 zz>?zz>?Pr-   