
    ddG
                        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ZddZ ej        d          Z ej        d          ZdddZdS )    )annotations)CallableN)quoteunquoteurlparse
urlunparse   )	_punycode)zhttp:zhttps:zmailto:urlstrreturnc                0   t          j        | d          }|j        rT|j        r|j        t          v r?	 |                    t          j        |j                            }n# t          $ r Y nw xY wt          j	        t          j
        |                    S )zvNormalize destination URLs in links

    ::

        [label]:   destination   'title'
                ^^^^^^^^^^^
    Tslashes_denote_hosthostname)mdurlparser   protocolRECODE_HOSTNAME_FOR_replacer
   to_ascii	Exceptionencodeformatr   parseds     @lib/python3.11/site-packages/markdown_it/common/normalize_url.pynormalizeLinkr      s     [$777F   	&/5H"H"H)2DV_2U2UVV    <V,,---   -A" "
A/.A/c                L   t          j        | d          }|j        rT|j        r|j        t          v r?	 |                    t          j        |j                            }n# t          $ r Y nw xY wt          j	        t          j
        |          t           j        dz             S )zSNormalize autolink content

    ::

        <destination>
         ~~~~~~~~~~~
    Tr   r   %)r   r   r   r   r   r   r
   
to_unicoder   decoder   DECODE_DEFAULT_CHARSr   s     r   normalizeLinkTextr&   (   s     [$777F   	&/5H"H"H)2Fv2W2WXX    <V,,e.H3.NOOOr    z!^(vbscript|javascript|file|data):z!^data:image\/(gif|png|jpeg|webp);	validatorCallable | Noneboolc                    | ||           S |                                                                  } t                              |           r't	          t
                              |                     n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'   s     r   validateLinkr0   G   se     y~~
))++



C-9-@-@-E-EO4##C(()))4O    )r   r   r   r   )N)r   r   r'   r(   r   r)   )
__future__r   collections.abcr   reurllib.parser   r   r   r   r    r
   r   r   r&   compiler-   r/   r0    r1   r   <module>r9      s    " " " " " " $ $ $ $ $ $ 				 = = = = = = = = = = = =       4 . . . .4P P P P6 rz>??rz>??P P P P P P Pr1   