
    wi
                        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ZddZ ej        d          Z ej        d          ZdddZdS )    )annotations)Callable)suppressN)quoteunquoteurlparse
urlunparse   )	_punycode)zhttp:zhttps:zmailto:urlstrreturnc                d   t          j        | d          }|j        rn|j        r|j        t          v rYt          t                    5  |                    t          j	        |j                            }ddd           n# 1 swxY w Y   t          j
        t          j        |                    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   parseds     x/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/markdown_it/common/normalize_url.pynormalizeLinkr       s     [$777F  SOS%2EEEi   	S 	S__i.@.Q.Q_RRF	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S <V,,---   .BBBc                   t          j        | d          }|j        rn|j        r|j        t          v rYt          t                    5  |                    t          j	        |j                            }ddd           n# 1 swxY w Y   t          j
        t          j        |          t           j        dz             S )zSNormalize 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     [$777F  UOU%2EEEi   	U 	U__i.B6?.S.S_TTF	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U <V,,e.H3.NOOOr!   z!^(vbscript|javascript|file|data):z!^data:image\/(gif|png|jpeg|webp);	validatorCallable[[str], bool] | 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   validateLinkr1   F   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   
contextlibr   reurllib.parser   r   r   r	   r    r   r   r    r'   compiler.   r0   r1    r2   r   <module>r;      s   " " " " " " $ $ $ $ $ $       				 = = = = = = = = = = = =       4 . . . .2P P P P4 rz>??rz>??P P P P P P Pr2   