HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberPanel/lib64/python3.10/site-packages/django/utils/__pycache__/html.cpython-310.pyc
o

�h=�@sdZddlZddlZddlZddlmZddlmZmZm	Z	m
Z
mZmZddl
mZddlmZmZmZmZddlmZmZddlmZdd	lmZmZmZdd
lmZee�dd��Ze d
�de d�de d�de d�de d�de d�de d�de d�de d�de d�d e d!�d"e d#�d$iZ!e!�"d%d&�e#d'�D��ee�d(d)��Z$e d�de d�de d�diZ%dId*d+�Z&d,d-�Z'd.d/�Z(d0d1�Z)edJd3d4��Z*Gd5d6�d6e�Z+d7d8�Z,ed9d:��Z-ed;d<��Z.d=d>�Z/Gd?d@�d@e0�Z1GdAdB�dB�Z2e2�Z3edKdCdD��Z4dEdF�Z5dGdH�Z6dS)Lz'HTML utilities suitable for global use.�N)�
HTMLParser)�	parse_qsl�quote�unquote�	urlencode�urlsplit�
urlunsplit)�punycode)�Promise�cached_property�	keep_lazy�keep_lazy_text)�RFC3986_GENDELIMS�RFC3986_SUBDELIMS)�_lazy_re_compile)�SafeData�
SafeString�	mark_safe)�normalize_newlinescCstt�t|���S)a
    Return the given text with ampersands, quotes and angle brackets encoded
    for use in HTML.

    Always escape input, even if it's already escaped and marked as such.
    This may result in double-escaping. If this is a concern, use
    conditional_escape() instead.
    )r�html�escape�str��text�r�G/usr/local/CyberPanel/lib/python3.10/site-packages/django/utils/html.pyrs
r�\z\u005C�'z\u0027�"z\u0022�>z\u003E�<z\u003C�&z\u0026�=z\u003D�-z\u002D�;z\u003B�`z\u0060u
z\u2028u
z\u2029ccs$�|]
}td|�d|fVqdS)z%cz\u%04XN)�ord)�.0�zrrr�	<genexpr>.s�"r)� cCstt|��t��S)z4Hex encode characters for use in JavaScript strings.)rr�	translate�_js_escapes��valuerrr�escapejs1�r/cCsXddlm}tj||p|d��t�}|rd}|t|�f}nd}t|�f}t|g|�R�S)z�
    Escape all the HTML/XML special characters with their unicode escapes, so
    value is safe to be output anywhere except for inside a tag attribute. Wrap
    the escaped JSON in a script tag.
    r)�DjangoJSONEncoder)�clsz3<script id="{}" type="application/json">{}</script>z+<script type="application/json">{}</script>)�django.core.serializers.jsonr1�json�dumpsr+�_json_script_escapesr�format_html)r.�
element_id�encoderr1�json_str�template�argsrrr�json_script>s�
r=cCs,t|t�r	t|�}t|d�r|��St|�S)z�
    Similar to escape(), except that it doesn't operate on pre-escaped strings.

    This function relies on the __html__ convention used both by Django's
    SafeData class and by third-party libraries like markupsafe.
    �__html__)�
isinstancer
r�hasattrr>rrrrr�conditional_escapeRs


rAcOs0tt|�}dd�|��D�}t|j|i|���S)z�
    Similar to str.format, but pass all arguments through conditional_escape(),
    and call mark_safe() on the result. This function should be used instead
    of str.format or % interpolation to build up small HTML fragments.
    cSsi|]	\}}|t|��qSr)rA)r'�k�vrrr�
<dictcomp>hszformat_html.<locals>.<dictcomp>)�maprA�itemsr�format)�
format_stringr<�kwargs�	args_safe�kwargs_saferrrr7as
r7cs tt|���fdd�|D���S)a�
    A wrapper of format_html, for the common case of a group of arguments that
    need to be formatted using the same format string, and then joined using
    'sep'. 'sep' is also passed through conditional_escape.

    'args_generator' should be an iterator that returns the sequence of 'args'
    that will be passed to format_html.

    Example:

      format_html_join('
', "<li>{} {}</li>", ((u.first_name, u.last_name)
                                                  for u in users))
    c3s �|]}t�g|�R�VqdS�N)r7)r'r<�rHrrr){s�
�z#format_html_join.<locals>.<genexpr>)rrA�join)�seprH�args_generatorrrMr�format_html_joinls
��rQFcCsDt|�}t�dt|��}|rdd�|D�}ndd�|D�}d�|�S)z$Convert newlines into <p> and <br>s.z
{2,}cSs g|]}dt|��dd��qS�z	<p>%s</p>�
z<br>)r�replace�r'�prrr�
<listcomp>�s zlinebreaks.<locals>.<listcomp>cSsg|]
}d|�dd��qSrR�rTrUrrrrW�sz

)r�re�splitrrN)r.�
autoescape�parasrrr�
linebreaks�s
r]cs<eZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Z�ZS)�
MLStrippercs t�jdd�|��g|_dS)NF)�convert_charrefs)�super�__init__�reset�fed��self��	__class__rrra�s
zMLStripper.__init__cCs|j�|�dSrL�rc�append)re�drrr�handle_data�szMLStripper.handle_datacC�|j�d|�dS)Nz&%s;rh�re�namerrr�handle_entityref��zMLStripper.handle_entityrefcCrl)Nz&#%s;rhrmrrr�handle_charref�rpzMLStripper.handle_charrefcCsd�|j�S�N�)rNrcrdrrr�get_data�szMLStripper.get_data)	�__name__�
__module__�__qualname__rarkrorqrt�
__classcell__rrrfrr^�sr^cCs t�}|�|�|��|��S)z<
    Internal tag stripping utility used by strip_tags.
    )r^�feed�closert)r.�srrr�_strip_once�s
r|cCsRt|�}d|vr'd|vr't|�}|�d�|�d�kr	|S|}d|vr'd|vs|S)z-Return the given HTML with all tags stripped.r r)rr|�count)r.�	new_valuerrr�
strip_tags�s��rcCst�ddt|��S)z7Return the given HTML with spaces between tags removed.z>\s+<z><)rY�subrr-rrr�strip_spaces_between_tags�r0r�cCs�dd�}zt|�\}}}}}Wn
ty||�YSwzt|�}Wn
ty0||�YSw|rBdd�t|dd�D�}t|�}||�}||�}t|||||f�S)z'Quote a URL if it isn't already quoted.cSst|�}t|ttdd�S)N�~)�safe)rrrr)�segmentrrr�
unquote_quote�sz%smart_urlquote.<locals>.unquote_quotecSs$g|]}t|d�t|d�f�qS)r�)r)r'�qrrrrW�s��z"smart_urlquote.<locals>.<listcomp>T)�keep_blank_values)r�
ValueErrorr	�UnicodeErrorrrr)�urlr��scheme�netloc�path�query�fragment�query_partsrrr�smart_urlquote�s&��
�r�cs$eZdZ�fdd�Zdd�Z�ZS)�
CountsDictcs t�jg|�|�R�||_dSrL)r`ra�word)rer�r<rIrfrrra�s
zCountsDict.__init__cCs|j�|�||<||SrL)r�r})re�keyrrr�__missing__�szCountsDict.__missing__)rurvrwrar�rxrrrfrr��sr�c@s�eZdZdZdZddgZedej�Z	edej�Z
ed�ZdZd	Z
ddd
�Zd
ddd�dd�Zdd�Zedd��Zedd��Zedd��Zdd�Zedd��Zd
S)�Urlizeram
    Convert any URLs in text into clickable links.

    Work on http://, https://, www. links, and also on links ending in one of
    the original seven gTLDs (.com, .edu, .gov, .int, .mil, .net, and .org).
    Links can have trailing punctuation (periods, commas, close-parens) and
    leading punctuation (opening parens) and it'll still do the right thing.
    z.,:;!)�(�))�[�]z^https?://\[?\wz>^www\.|^(?!http)\w[^@]+\.(com|edu|gov|int|mil|net|org)($|/.*)$z([\s<>"']+)zmailto:{local}@{domain}z!<a href="{href}"{attrs}>{url}</a>NFcs:t|t���j�t|��}d������fdd�|D��S)a?
        If trim_url_limit is not None, truncate the URLs in the link text
        longer than this limit to trim_url_limit - 1 characters and append an
        ellipsis.

        If nofollow is True, give the links a rel="nofollow" attribute.

        If autoescape is True, autoescape the link text and URLs.
        rsc	s g|]}�j|����d��qS))�
safe_input�trim_url_limit�nofollowr[)�handle_word)r'r��r[r�r�rer�rrrWs���z$Urlizer.__call__.<locals>.<listcomp>)r?r�
word_split_rerZrrN)rerr�r�r[�wordsrr�r�__call__s

��zUrlizer.__call__�r�r�r[cCsdd|vsd|vsd|vr�|�|�\}}}d}	|rdnd}
|j�|�r*tt�|��}	n=|j�|�r:tdt�|��}	n-d|vrg|�|�rg|�dd�\}}zt	|�}Wnt
y\|YSw|jj||d�}	d}
|	r�|j
||d	�}
|r�|s�t|�t|�}}t|
�}
|jjt|	�|
|
d
�}t|�|�|���S|r�t|�S|r�t|�S|S|r�t|�S|r�t|�S|S)N�.�@�:z rel="nofollow"rsz	http://%sr�)�local�domain)�limit)�href�attrsr�)�trim_punctuation�
simple_url_re�matchr�r�unescape�simple_url_2_re�is_email_simple�rsplitr	r��mailto_templaterG�trim_urlr�url_templater)rer�r�r�r�r[�lead�middle�trailr��
nofollow_attrr�r��trimmedrrrr�sL	���zUrlizer.handle_wordcCs2|dus
t|�|kr|Sd|dtd|d��S)Nu%s…rr�)�len�max)re�xr�rrrr�RszUrlizer.trim_urlcCsd�t|j����Srr)rN�dict�wrapping_punctuation�keysrdrrr�wrapping_punctuation_openingsWsz%Urlizer.wrapping_punctuation_openingscCs|j�dd�S)Nr$rs)�trailing_punctuation_charsrTrdrrr�'trailing_punctuation_chars_no_semicolon[sz/Urlizer.trailing_punctuation_chars_no_semicoloncCs
d|jvS)Nr$)r�rdrrr�(trailing_punctuation_chars_has_semicolon_s
z0Urlizer.trailing_punctuation_chars_has_semicoloncCs�|�|j�}|dt|�t|��}d}d}t|d�}|r�|r�d}|jD]5\}}||||krY|�|�}	|	|krY||||}
||
d�}|d|
�}d}|||
8<q$|�|j�}	|	|krr|t|	�d�|}|	}d}|jr�|�d�r�|�	d�}|dkr�d}n||d�}
t
�|
�}||
kp�|�d�}|r�|�d�}	t|�t|	�}|dkr�|d	kr�|t|	�d	d�|}|	d}n|t|	�d�|}|	}d}|r�|s|||fS)
zp
        Trim trailing and wrapping punctuation from `word`. Return the items of
        the new state.
        NrsT)r�Fr$r!���r�)�lstripr�r�r�r��rstripr�r��endswith�rfindrr�)rer�r�r�r��trimmed_something�counts�opening�closing�	rstripped�strip�amp�	can_strip�potential_entity�escaped�amount_strippedrrrr�csP

�



�
)zUrlizer.trim_punctuationcCsbd|vs|�d�s|�d�rdSz	|�d�\}}Wn
ty#YdSwd|vs-|�d�r/dSdS)z1Return True if value looks like an email address.r�Fr�T)�
startswithr�rZr�)r.�p1�p2rrrr��s�zUrlizer.is_email_simple�NFF)rurvrw�__doc__r�r�rrY�
IGNORECASEr�r�r�r�r�r�r�r�rr�r�r�r��staticmethodr�rrrrr��s4	�
�4


8r�cCst||||d�S)Nr�)�urlizer)rr�r�r[rrr�urlize�s�r�cCs|�dd�S)z�
    Avoid text wrapping in the middle of a phrase by adding non-breaking
    spaces where there previously were normal spaces.
    � � rXr-rrr�avoid_wrapping�sr�csRd|jvrtd|j��d|jvrtd|j��|j��fdd�|_dd�|_|S)z�
    A decorator that defines the __html__ method. This helps non-Django
    templates to detect classes whose __str__ methods return SafeString.
    r>z;can't apply @html_safe to %s because it defines __html__().�__str__zAcan't apply @html_safe to %s because it doesn't define __str__().cst�|��SrL)rrd��	klass_strrr�<lambda>�szhtml_safe.<locals>.<lambda>cSst|�SrL)rrdrrrr��s)�__dict__r�rur�r>)�klassrr�r�	html_safe�s 
��
��
r�)NN)Fr�)7r�rr4rY�html.parserr�urllib.parserrrrrr�django.utils.encodingr	�django.utils.functionalr
rrr
�django.utils.httprr�django.utils.regex_helperr�django.utils.safestringrrr�django.utils.textrrr&r,�update�ranger/r6r=rAr7rQr]r^r|rr�r�r�r�r�r�r�r�r�rrrr�<module>sn 

�
�



%
?