File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/markdown_it/common/__pycache__/normalize_url.cpython-310.pyc
Back
o ;j � @ s� d dl mZ d dlmZ d dlmZ d dlZd dlmZm Z m Z mZ d dlZddl mZ dZddd �Zddd�Ze�d�Ze�d�Zdddd�ZdS )� )�annotations)�Callable)�suppressN)�quote�unquote�urlparse� urlunparse� )� _punycode)zhttp:zhttps:zmailto:�url�str�returnc C sp t j| dd�}|jr0|jr|jtv r0tt�� |jt� |j�d�}W d � n1 s+w Y t � t �|��S )zvNormalize destination URLs in links :: [label]: destination 'title' ^^^^^^^^^^^ T�Zslashes_denote_host��hostnameN)�mdurl�parser �protocol�RECODE_HOSTNAME_FORr � Exception�_replacer Zto_ascii�encode�format�r �parsed� r �T/opt/saltstack/salt/lib/python3.10/site-packages/markdown_it/common/normalize_url.py� normalizeLink s � �r c C sx t j| dd�}|jr0|jr|jtv r0tt�� |jt� |j�d�}W d � n1 s+w Y t � t �|�t jd �S )zSNormalize autolink content :: <destination> ~~~~~~~~~~~ Tr r N�%) r r r r r r r r r Z to_unicode�decoder ZDECODE_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 |dur|| �S | � � �� } t�| �rtt�| ��S dS )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"