Files
cms-website/.deps_siteforge_v812/bleach/__pycache__/linkifier.cpython-312.pyc
T

194 lines
16 KiB
Plaintext
Raw Normal View History

Ë
îÅÙjNãóH—ddlZddlmZddlmZddlmZejgZdj«Z
e
j«e
ejfd„Z
e
«Zejdej «Ze
fd„Ze«ZGd „d
«ZGd „d ej*«Zy)
éN©Ú callbacks)Ú
html5lib_shim)Úalphabetize_attributesa¯ac ad ae aero af ag ai al am an ao aq ar arpa as asia at au aw ax az
ba bb bd be bf bg bh bi biz bj bm bn bo br bs bt bv bw by bz ca cat
cc cd cf cg ch ci ck cl cm cn co com coop cr cu cv cx cy cz de dj dk
dm do dz ec edu ee eg er es et eu fi fj fk fm fo fr ga gb gd ge gf gg
gh gi gl gm gn gov gp gq gr gs gt gu gw gy hk hm hn hr ht hu id ie il
im in info int io iq ir is it je jm jo jobs jp ke kg kh ki km kn kp
kr kw ky kz la lb lc li lk lr ls lt lu lv ly ma mc md me mg mh mil mk
ml mm mn mo mobi mp mq mr ms mt mu museum mv mw mx my mz na name nc ne
net nf ng ni nl no np nr nu nz om org pa pe pf pg ph pk pl pm pn post
pr pro ps pt pw py qa re ro rs ru rw sa sb sc sd se sg sh si sj sk sl
sm sn so sr ss st su sv sx sy sz tc td tel tf tg th tj tk tl tm tn to
tp tr travel tt tv tw tz ua ug uk us uy uz va vc ve vg vi vn vu wf ws
xn xxx ye yt yu za zm zwc
ó—tjdjdjt |««djt |«««tj
tj ztjz«S)aDBuilds the url regex used by linkifier
If you want a different set of tlds or allowed protocols, pass those in
and stomp on the existing ``url_re``::
from bleach import linkifier
my_url_re = linkifier.build_url_re(my_tlds_list, my_protocols)
linker = LinkifyFilter(url_re=my_url_re)
ab\(* # Match any opening parentheses.
\b(?<![@.])(?:(?:{0}):/{{0,3}}(?:(?:\w+:)?\w+@)?)? # http://
([\w-]+\.)+(?:{1})(?:\:[0-9]+)?(?!\.\w)\b # xx.yy.tld(:##)?
(?:[/?][^\s\{{\}}\|\\\^\[\]`<>"]*)?
# /path/zz (excluding "unsafe" chars from RFC 1738,
# except for # and ~, which happen in practice)
Ú|)ÚreÚcompileÚformatÚjoinÚsortedÚ
IGNORECASEÚVERBOSEÚUNICODE)ÚtldsÚ protocolss úTC:\Users\30997\AppData\Local\Temp\pip-target-6g32zz5s\lib\python\bleach/linkifier.pyÚ build_url_rersa€ô �:‰:ð ÷
‰FØ �H‰H”V˜IÓ&Ó '¨¯©´&¸³,Ó)?ó
ô �
‰
œŸ
™
Ñ"¤R§Z¡ZÑ/ó ð óz^[\w-]+:/{0,3}cóÊ—tjdjdj|««tjtj
ztj z«S)a'Builds the email regex used by linkifier
If you want a different set of tlds, pass those in and stomp on the existing ``email_re``::
from bleach import linkifier
my_email_re = linkifier.build_email_re(my_tlds_list)
linker = LinkifyFilter(email_re=my_url_re)
a4(?<!//)
(([-!#$%&'*+/=?^_`{{}}|~0-9A-Z]+
(\.[-!#$%&'*+/=?^_`{{}}|~0-9A-Z]+)* # dot-atom
|^"([\001-\010\013\014\016-\037!#-\[\]-\177]
|\\[\001-\011\013\014\016-\177])*" # quoted-string
)@(?:[A-Z0-9](?:[A-Z0-9-]{{0,61}}[A-Z0-9])?\.)+(?:{0})) # domain
r)r r
r r rÚ MULTILINEr)rs rÚbuild_email_rer?sL€ô �:‰:ð ÷
‰FØ �H‰H�T‹Nó
ô �
‰
œŸ ™ Ñ$¤r§z¡zÑ1ó ð rcó>—eZdZdZeddeeejfd„Z d„Z
y)ÚLinkeražConvert URL-like strings in an HTML fragment to links
This function converts strings that look like URLs, domain names and email
addresses in text that may be an HTML fragment to links, while preserving:
1. links already in the string
2. urls found in attributes
3. email addresses
linkify does a best-effort approach and tries to recover from bad
situations due to crazy text.
NFcóö—||_||_||_||_||_t j |ddd¬«|_t jd«|_ t jdddd¬«|_ y)aÜCreates a Linker instance
:arg list callbacks: list of callbacks to run when adjusting tag attributes;
defaults to ``bleach.linkifier.DEFAULT_CALLBACKS``
:arg list skip_tags: list of tags that you don't want to linkify the
contents of; for example, you could set this to ``['pre']`` to skip
linkifying contents of ``pre`` tags
:arg bool parse_email: whether or not to linkify email addresses
:arg re url_re: url matching regex
:arg re email_re: email matching regex
:arg list-of-strings recognized_tags: the list of tags that linkify knows about;
everything else gets escaped
:returns: linkified text as unicode
FT)ÚtagsÚstripÚconsume_entitiesÚnamespaceHTMLElementsÚetreeÚalways)Úquote_attr_valuesÚomit_optional_tagsÚsanitizeÚalphabetical_attributesN) rÚ skip_tagsÚ parse_emailÚurl_reÚemail_rerÚBleachHTMLParserÚparserÚ
getTreeWalkerÚwalkerÚBleachHTMLSerializerÚ
serializer)Úselfrr&r'r(r)Úrecognized_tagss rÚ__init__zLinker.__init__lsz€ð<#ˆŒØ"ˆŒØ&ˆÔ؈Œ Ø ˆŒ
ô$×4Ñ4Ø ØØ!Ø"'ô 
ˆŒ ô $×1Ñ1°'Ó:ˆŒ Ü'×<Ñ<Ø&Ø$àà$)ô

ˆ�rcóN—t|t«s td«‚|sy|jj |«}t |j
|«|j|j|j|j|j¬«}|jj|«S)z¹Linkify specified text
:arg str text: the text to add links to
:returns: linkified text as unicode
:raises TypeError: if ``text`` is not a text type
zargument must be of text typeÚ)Úsourcerr&r'r(r))Ú
isinstanceÚstrÚ TypeErrorr+Ú
parseFragmentÚ
LinkifyFilterr-rr&r'r(r)r/Úrender)r0ÚtextÚdomÚfiltereds rÚlinkifyzLinker.linkify¢s†€ô˜$¤Ô$ÜÐ;Ó<Ð <áØà�k‰k×'Ñ'¨Ó-ˆÜ Ø—;‘;˜sÓ#Ø—n‘nØ—n‘nØ×(Ñ(Ø—;‘;Ø—]‘]ô

ˆð�‰×%Ñ% hÓ/Ð/r) Ú__name__Ú
__module__Ú __qualname__Ú__doc__ÚDEFAULT_CALLBACKSÚURL_REÚEMAIL_RErÚ HTML_TAGSr2r?©rrrr]s,„ñ ð $ØØØØØ%×/Ñ/ó4
ól0rrcó\‡—eZdZdZeddeefˆfd„ Zd„Zd„Z d„Z
d„Z d „Z d
„Z
ˆfd „ZˆxZS) r:aDhtml5lib filter that linkifies text
This will do the following:
* convert email addresses into links
* convert urls into links
* edit existing links by running them through callbacks--the default is to
add a ``rel="nofollow"``
This filter can be used anywhere html5lib filters can be used.
NFcó‚•—tt|� |«|xsg|_|xsg|_||_||_||_y)a[Creates a LinkifyFilter instance
:arg TreeWalker source: stream
:arg list callbacks: list of callbacks to run when adjusting tag attributes;
defaults to ``bleach.linkifier.DEFAULT_CALLBACKS``
:arg list skip_tags: list of tags that you don't want to linkify the
contents of; for example, you could set this to ``['pre']`` to skip
linkifying contents of ``pre`` tags
:arg bool parse_email: whether or not to linkify email addresses
:arg re url_re: url matching regex
:arg re email_re: email matching regex
N)Úsuperr:r2rr&r'r(r))r0r5rr&r'r(r)Ú __class__s €rr2zLinkifyFilter.__init__Ìs@ø€ô6 Œm˜TÑ+¨FÔ3à"š bˆŒØ"š bˆŒØ&ˆÔàˆŒ Ø ˆ�
rcóB—|jD]}|||«}|�Œy|S)a¾Given an attrs dict and an is_new bool, runs through callbacks
Callbacks can return an adjusted attrs dict or ``None``. In the case of
``None``, we stop going through callbacks and return that and the link
gets dropped.
:arg dict attrs: map of ``(namespace, name)`` -> ``value``
:arg bool is_new: whether or not this link was added by linkify
:returns: adjusted attrs dict or ``None``
Nr)r0ÚattrsÚis_newÚcbs rÚapply_callbackszLinkifyFilter.apply_callbacksðs-€ð—.”.ˆBÙ�u˜fÓ%ˆE؉}Ùð!ðˆ rcór—g}|D] }|d}|dvsŒ
|j|d«Œ"dj|«S)z;Extracts and squashes character sequences in a token streamÚtype)Ú
CharactersÚSpaceCharactersÚdatar4)Úappendr )r0Ú
token_listÚoutÚtokenÚ
token_types rÚextract_character_dataz$LinkifyFilter.extract_character_datasE€ð&ˆÛˆEؘv™ˆJØÐ>Ò>Ø—
‘
˜5 ™=Õ)ð ð
�w‰w�s‹|Ðrc #óÆK—|D�]W}|ddk(�rG|d}g}d}|jj|«D]ì}|j«|kDr%|jd|||j«dœ«d|j d«z|j d«dœ}|j |d«}|€$|jd|j d«dœ«nD|j
d
d «}t|«}|jd d
|dœdt|«dœdd
dœg«|j«}Œî|r2|t|«kr|jd||d dœ«|D]} | –—Œ�ŒT|–—�ŒZy ­w)z*Handle email addresses in character tokensrSrTrVr©rSrVz mailto:%s©)NÚhrefÚ_textTNrar4ÚStartTagÚa©rSÚnamerVÚEndTag©rSre) r)ÚfinditerÚstartrWÚgrouprQÚpoprÚextendr7ÚendÚlen)
r0Úsrc_iterrZr<Ú
new_tokensrmÚmatchrNraÚ new_tokens
rÚhandle_email_addressesz$LinkifyFilter.handle_email_addressessvèø€äˆEØ�V‰}  Ó,ؘV‘}�Ø�
Ø�ð"Ÿ]™]×3Ñ3°DÖ9�EØ—{‘{“} sÒ*Ø"×)Ñ)Ø%1¸4ÀÀeÇkÁkÃmÐ;TÑUôð)4°e·k±kÀ!³nÑ(DØ!&§¡¨Q£ñ�Eð!×0Ñ0°¸Ó=�Eà�}à"×)Ñ)Ø%1¸5¿;¹;Àq»>ÑJõð !&§ ¡ ¨'°2Ó 6˜Ü 6°uÓ =˜Ø"×)Ñ)à)3¸SÈ%Ñ PØ)5¼sÀ5»zÑ JØ)1¸3Ñ ?ðôð Ÿ)™)›+‘Cð?:ñBðœS ›Y’Ø"×)Ñ)°<ÈÈcÈdÈÑ*TÔUã%/˜ Ø'›ð&0ñàŒKñgùs‚EE!có8—dx}}|r�|jd«r&|dz}|dd}|jd«r
d|z}|dd}Œ9|jd«rd|vr |dd}d|z}ŒY|jd«r |dd}d|z}Œu|jd«r |dd}d|z}Œ‘ |||fS) zgStrips non-url bits from the url
This accounts for over-eager matching by the regex.
r4Ú(éNÚ)éÿÿÿÿÚ,Ú.)Ú
startswithÚendswith)r0ÚfragmentÚprefixÚsuffixs rÚstrip_non_url_bitsz LinkifyFilter.strip_non_url_bitsVsè€ð Ј�áð×"Ñ" 3Ô'Ø #™�Ø# A B˜<�à×$Ñ$ SÔ)Ø  6™\�FØ'¨¨˜}�HØð× Ñ  Ô%¨#°XÑ*=Ø# C R˜=�ؘv™�Øð× Ñ  Ô%Ø# C R˜=�ؘv™�Øð× Ñ  Ô%Ø# C R˜=�ؘv™�Øð
à˜ Ð'Ð'rc #óÀK—d}|D�]Ò}|r|ddk(r
|ddk(rd}|–—Œ|ddk(r|ddk(rd}|–—Œ4|ddk(�r’|d }g}d
}|jj|«D�]6}|j«|kDr%|jd|||j«d œ«|j d