Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_htmlparser.cpython-310.pyc
o

�9j���@s�dZddlZddlZddlZddlmZdZedZGdd�dej	j
�ZGdd	�d	e�ZGd
d�de�Z
Gdd
�d
e�ZGdd�dej�ZGdd�de�ZGdd�de�Zedkr_e��dSdS)zTests for HTMLParser.py.�N)�supportuo<!-- not a comment --><not a='start tag'><![CDATA[not a cdata]]><!not a bogus comment></not a bogus comment>☃z&amp;&#9786;c@sreZdZdd�dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�EventCollectorF��	autocdatacOsH||_g|_|jj|_tjjj|g|�Ri|��|r"|�d�dSdS)NF)r�events�append�html�parser�
HTMLParser�__init__�_set_support_cdata)�selfr�args�kw�r�+/usr/lib/python3.10/test/test_htmlparser.pyrs
�zEventCollector.__init__cCsjg}d}|jD](}|d}||krdkr(nnd|dd|df|d<n|�|�|}q||_|S)Nr�data����)rr)r
�L�prevtype�event�typerrr�
get_events s

zEventCollector.get_eventscCs4|�d||f�|jr|dkr|�d�dSdSdS)N�starttag�svgT�rrr�r
�tag�attrsrrr�handle_starttag1s�zEventCollector.handle_starttagcCs|�d||f�dS)N�startendtag�rrrrr�handle_startendtag6sz!EventCollector.handle_startendtagcCs2|�d|f�|jr|dkr|�d�dSdSdS)N�endtagrFr)r
rrrr�
handle_endtag9s�zEventCollector.handle_endtagcC�|�d|f�dS)N�commentr"�r
rrrr�handle_comment@�zEventCollector.handle_commentcCr&)N�charrefr"r(rrr�handle_charrefCr*zEventCollector.handle_charrefcCr&)Nrr"r(rrr�handle_dataFr*zEventCollector.handle_datacCr&)N�declr"r(rrr�handle_declIr*zEventCollector.handle_declcCr&)N�	entityrefr"r(rrr�handle_entityrefLr*zEventCollector.handle_entityrefcCr&)N�pir"r(rrr�	handle_piOr*zEventCollector.handle_picCr&)N�unknown declr")r
r.rrr�unknown_declRr*zEventCollector.unknown_declN)�__name__�
__module__�__qualname__rrr r#r%r)r,r-r/r1r3r5rrrrrsrc@�eZdZdd�ZdS)�EventCollectorExtracCs$t�|||�|�d|��f�dS)N�
starttag_text)rr r�get_starttag_textrrrrr Xsz#EventCollectorExtra.handle_starttagN)r6r7r8r rrrrr:Vsr:c@seZdZdd�Zdd�ZdS)�EventCollectorCharrefscC�|�d�dS�Nz6This should never be called with convert_charrefs=True��failr(rrrr,_�z%EventCollectorCharrefs.handle_charrefcCr>r?r@r(rrrr1brBz'EventCollectorCharrefs.handle_entityrefN)r6r7r8r,r1rrrrr=]sr=c@r9)�EventCollectorNoNormalizecCs|jS�N)r�r
rrrrisz$EventCollectorNoNormalize.get_eventsN)r6r7r8rrrrrrChsrCc@s&eZdZdd�Zddd�Zdd�ZdS)	�TestCaseBasecCs
tdd�S�NF��convert_charrefs)rrErrr�
get_collectoros
zTestCaseBase.get_collectorNcCsv|dur|��}|}|D]}|�|�q|��|��}||kr9|�dt|�dt�|�dt�|��dSdS)Nz6received events did not match expected events
Source:
z
Expected:
z
Received:
)rJ�feed�closerrA�repr�pprint�pformat)r
�source�expected_events�	collectorr	�srrrr�
_run_checkrs(����
��zTestCaseBase._run_checkcCs|�||tdd��dSrG)rTr:)r
rPrrrr�_run_check_extra�s�zTestCaseBase._run_check_extrarD)r6r7r8rJrTrUrrrrrFms
rFc@sFeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Ze�dgd��dd��Ze�dgd��dd��Ze�d d!d"g�d#d$��Ze�d gd%��d&d'��Zd(d)�Zd*d+�Ze�d,gd-��d.d/��Ze�d gd0��d1d2��Ze�d gd0��d3d4��Ze�d5gd6��d7d8��Ze�d9gd:��d;d<��Ze�d9gd=��d>d?��Zd@dA�ZdBdC�ZdDdE�ZdFdG�Z dHdI�Z!dJdK�Z"dLdM�Z#dNdO�Z$dPdQ�Z%dRdS�Z&dTdU�Z'dVdW�Z(dXdY�Z)dZd[�Z*d\d]�Z+e�dgd^��d_d`��Z,dadb�Z-dcdd�Z.e�dgde��dfdg��Z/dhdi�Z0djdk�Z1e�2dl�dmdn��Z3doS)p�HTMLParserTestCasecCs |�ddg�|�ddg�dS)Nz<?processing instruction>)r2zprocessing instructionz<?processing instruction ?>)r2zprocessing instruction ?�rTrErrr� test_processing_instruction_only�s�
�z3HTMLParserTestCase.test_processing_instruction_onlycCsB|�ddddddgfddddddd	d
dgfdd
dddddg�dS)Nz�
<!DOCTYPE html PUBLIC 'foo'>
<HTML>&entity;&#32;
<!--comment1a
-></foo><bar>&lt;<?pi?></foo<bar
comment1b-->
<Img sRc='Bar' isMAP>sample
text
&#x201C;
<!--comment2a-- --comment2b-->
</Html>
�r�
)r.zDOCTYPE html PUBLIC 'foo'rr)r0�entity)r+�32)r'z4comment1a
-></foo><bar>&lt;<?pi?></foo<bar
comment1b�img)�src�Bar)�ismapN)rzsample
text
)r+�x201C)r'zcomment2a-- --comment2b�r$rrWrErrr�test_simple_html�s(��z#HTMLParserTestCase.test_simple_htmlcCs6|�dddgfddg�|�dgddgfddg�dS)	Nz
<p>&#bad;</p>r�p)rz&#bad;�r$rdz<div>&#bad;</div>�div�r$rfrWrErrr�test_malformatted_charref�s�
�z,HTMLParserTestCase.test_malformatted_charrefcCs|�dddg�dS)Nz&entityref foo)r0r0)rz foorWrErrr�test_unclosed_entityref�s
�z*HTMLParserTestCase.test_unclosed_entityrefcCs$|�dddgfddgfddg�dS)Nz<a><b></a></b>r�a�b�r$rj�r$rkrWrErrr�test_bad_nesting�s
�z#HTMLParserTestCase.test_bad_nestingcC�|�ddg�dS)N�#this text & contains & ampersands &)rrprWrErrr�test_bare_ampersands��
�z'HTMLParserTestCase.test_bare_ampersandscCro)N�.this < text > contains < bare>pointy< brackets)rrsrWrErrr�test_bare_pointy_brackets�rrz,HTMLParserTestCase.test_bare_pointy_bracketscCs0|�ddddgfg�|�ddddgfg�dS)N�	<a b='<'>rrj�rk�<�	<a b='>'>�rk�>rWrErrr�test_starttag_end_boundary�sz-HTMLParserTestCase.test_starttag_end_boundarycCs�dddgfg}|�dg|�|�ddg|�|�ddg|�|�d	d
g|�|�ddg|�|�d
dg|�dddgfg}|�dg|�|�ddg|�|�ddg|�|�d	dg|�|�ddg|�|�ddg|�dg}|�ddg|�|�ddg|�|�ddg|�|�ddg|�|�dd g|�|�d!d"g|�|�d#d$g|�|�d%d&g|�|�d'd(g|�|�d)dg|�|�ddg|�dS)*Nrrjrvru�<a zb='<'>z<a bz='<'>z<a b=z'<'>z<a b='<z'>z<a b='<'rzryrxzb='>'>z='>'>z'>'>z<a b='>z<a b='>')r'�abc�z
<!--abc-->rwz	!--abc-->�<!z--abc-->�<!-z-abc-->�<!--zabc-->z<!--azbc-->z<!--abzc-->z<!--abcz-->z<!--abc-z->z	<!--abc--rW�r
�outputrrr�test_buffer_artefacts�s4z(HTMLParserTestCase.test_buffer_artefactscCs0gd�}|D]}|�d|dd|fg�qdS)N)
�HTMLzOHTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"z[HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"zbhtml PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"zfhtml PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"zYmath PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd"z�html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"zWsvg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"z'html PUBLIC "-//IETF//DTD HTML 2.0//EN"z,html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"z
<!DOCTYPE %s>r.�DOCTYPE rW)r
�dtds�dtdrrr�test_valid_doctypes�s
��z&HTMLParserTestCase.test_valid_doctypescCsN|�dddgfg�|�dddgfdg�|�dddgfddd	gfdg�dS)
Nz<p/>r!rdz<p></p>rrez<p><img src='foo' /></p>r])r^�foorWrErrr�test_startendtags��

�z#HTMLParserTestCase.test_startendtagcCs&d}|�|ddddgfd|fg�dS)Nz <foo:bar   
   one="1"	two=2   >rzfoo:bar)�one�1)�two�2r;)rU)r
rSrrr�test_get_starttag_texts

�z)HTMLParserTestCase.test_get_starttag_text�content)
z*<!-- not a comment --> &not-an-entity-ref;�<not a='start tag'>z<a href="" /> <p> <span></span>zfoo = "</scr" + "ipt>";zfoo = "</SCRIPT" + ">";zfoo = <
/script> z*<!-- document.write("</scr" + "ipt>"); -->z�
//<![CDATA[
document.write('<s'+'cript type="text/javascript" src="http://www.example.org/r='+new Date().getTime()+'"><\/s'+'cript>');
//]]>z 
<!-- //
var foo = 3.14;
// -->
u<!-- ☃ -->cC�,d|�d�}|�|ddgfd|fdg�dS)Nz<script>z	</script>r�scriptr�r$r�rW�r
r�rSrrr�test_script_content%s
�z&HTMLParserTestCase.test_script_content)z0a::before { content: "<!-- not a comment -->"; }z-a::before { content: "&not-an-entity-ref;"; }z-a::before { content: "<not a='start tag'>"; }ua::before { content: "☃"; }cCr�)Nz<style>z</style>r�styler�r$r�rWr�rrr�test_style_content<s

�z%HTMLParserTestCase.test_style_contentr�title�textareacCsjd|�dt�d|�d�}|�|d|gfdtfd|fg�d|�d|�d�}|�|d|gfdd|fg�dS)	Nrwrz�</rrr$z>&amp;</�r0�amp)�
SAMPLE_RCDATArT�r
rrPrrr�test_rcdata_contentHs�
�z&HTMLParserTestCase.test_rcdata_content)r��xmp�iframe�noembed�noframesr�cCs<d|�dt�d|�d�}|�|d|gfdtfd|fg�dS)Nrwrzr�rrr$��SAMPLE_RAWTEXTrTr�rrr�test_rawtext_contentWs
�z'HTMLParserTestCase.test_rawtext_contentc
Csddt�d�}|�|ddgfddddgfdd	d
ddd
dg
�|j|ddgfdtfdgtdd�d�dS)Nz
<noscript>z</noscript>r�noscript)r'z not a comment �not)rjz	start tag)r4zCDATA[not a cdata)r'znot a bogus comment)r$r�)ru☃r�)r+�9786)r$r�rT)�	scripting�rR)r�rTr)r
rPrrr�test_noscript_contentas(
�
�
�z(HTMLParserTestCase.test_noscript_contentcCs0td}d|��}|�|ddgfd|fg�dS)Nz</plaintext>z<plaintext>r�	plaintextrr�)r
r�rPrrr�test_plaintext_contentws

�z)HTMLParserTestCase.test_plaintext_contentr$)r��SCRIPTzscript zscript
zscript/zscript foo=barzscript foo=">"cCs@d}d|�d|�d�}|j|ddgfd|fdgtd	d
�d�dS)Nz�<!-- not a comment --> &not-an-entity-ref;
                  <a href="" /> </p><p> <span></span></style>
                  '</script' + '>'�<ScrIPt>r�rzrr�rr�FrHr��rTrC)r
r$r�rSrrr�test_script_closing_tags�
�z*HTMLParserTestCase.test_script_closing_tag)	r�r�r�r�r�r�r�r�r�cCs�||��|�d�|�d�|�d�|�d�|�d�fD](}d}d|���d|�d	|�d�}|j|d
|gfd|fd|fgtd
dd�d�qdS)N� rZ�/z foo=barz foo=">"z!<!-- not a comment --><i>Spam</i>rwrzr�rrr$FT�rIr�r�)�upperrTrC)r
rr$r�rSrrr�test_closing_tag�s��
��z#HTMLParserTestCase.test_closing_tagcCsld|�d|�d|�d|�d|�d�}d|�d|�d	|�d�}|j|d
|gfd|fd|fgtd
dd�d�dS)Nz< /z></ z></zx></z></u >rwrzr�rrr$FTr�r��rTr)r
rr�rPrrr�test_invalid_closing_tag�s$������

�z+HTMLParserTestCase.test_invalid_closing_tagz
tag,endtag)
)r�utıtle)r�uſtyle)r�uſtyle)r�ustyle)r�uıframe)r�u	noframeſ)r�u	noſcript)r�u	noscrıpt)r�uſcript)r�uscrıptcCs�d|�d�}d|�d|��}|j|d|gfd|fgtddd�d	�d|�d|�d
|�d�}|j|d|gfd|fd|fgtddd�d	�dS)Nz<br></rzrwrrFTr�r�r�r$r�)r
rr$r�rPrrr�!test_invalid_nonascii_closing_tag�s 
�
��

�z4HTMLParserTestCase.test_invalid_nonascii_closing_tagztail,end)�r~F�rwF�r�F)z</sF)z</scriptF)z	</script T)z</script foo=barT)z</script foo=">TcCsFd}d|�|��}|j|ddgfd|r|n||fgtdd�d�dS)	Nza = 123r�rr�rFrHr�r�)r
�tail�endr�rSrrr�test_eof_in_script�s�
�z%HTMLParserTestCase.test_eof_in_script)r�r�r�)z</tF)z</titleF)z</title T)z</title foo=barT)z</title foo=">TcCsrd|��}|j|ddgfdd|rdn|fgtdd�d	�|j|ddgfd
ddd|r,dn|fgtd
d�d	�dS)Nz<TitLe>Egg &amp; Spamrr�rz
Egg & Spamr~TrHr�)rzEgg r�z SpamFr�)r
r�r�rSrrr�test_eof_in_title�s
���
�z$HTMLParserTestCase.test_eof_in_titlecC�d}gd�}|�||�dS)Na.<!-- I'm a valid comment --><!--me too!--><!------><!-----><!----><!---><!--><!----I have many hyphens----><!-- I have a > in the middle --><!-- and I have -- in the middle! --><!--incorrectly-closed-comment--!><!----!><!----!--><!---- >--><!---!>--><!--!>--><!-- <!-- nested --> --><!--<!--><!--<!--!>))r'z I'm a valid comment )r'zme too!�r'z--�r'�-�r'r~r�r�)r'z--I have many hyphens--)r'z I have a > in the middle )r'z and I have -- in the middle! )r'zincorrectly-closed-commentr�)r'z--!)r'z-- >�r'z-!>)r'z!>)r'z
 <!-- nested )rz -->�r'rr�rW�r
r�expectedrrr�
test_comments�sz HTMLParserTestCase.test_commentscCr�)Nzs<!--[if IE & !(lte IE 8)]>aren't<![endif]--><!--[if IE 8]>condcoms<![endif]--><!--[if lte IE 7]>pretty?<![endif]-->))r'z%[if IE & !(lte IE 8)]>aren't<![endif])r'zf IE 8]>condcoms<![endif])r'z[if lte IE 7]>pretty?<![endif]rWr�rrr�
test_condcomssz HTMLParserTestCase.test_condcomsc
CsBdd�}|�|�j�gd�}dddgfddg}|D]}|jd	�|�||�d
�qdddgd�fdddg}|D]}|jd
�|�||�d
�q7|D],}d�|gd�}dddgfd|fddddgfd|fddg	}|jd�||�||�d
�qHd}tdt|��D]}|j|d|�d|d|�fg|�d
�q~|jddg|�d
�dS)NcSst�SrD)r=rrrr�<lambda>'sz:HTMLParserTestCase.test_convert_charrefs.<locals>.<lambda>)z&quot;z&#34;z&#x22;z&quotz&#34z&#x22rrj)�hrefzfoo"zar)rza"zrlz<a href="foo{0}zar">a{0}z</a>r�)r�"))�xr�)�yz"X)�zzX"z*{0}<a x="{0}" y="{0}X" z="X{0}">{0}</a>{0}�X�r�rr�r�r�z/{1}<script>{0}</script>{1}<style>{0}</style>{1}z&quo &# &#xr�no charrefs here)rr�)�
assertTruerIrT�format�join�range�len)r
rR�charrefsr�r+�textrr�rrr�test_convert_charrefs%sN
�������

�z(HTMLParserTestCase.test_convert_charrefsc
Cs.|�ddddgfdddddd	gfd
dg�dS)NzF<html <html>te>>xt&a<<bc</a></html>
<img src="URL><//img></html</html>rr)z<htmlN)rzte>>xt)r0rj�rrwzbc<)rjNrbrYrWrErrr�test_tolerant_parsingNs

��z(HTMLParserTestCase.test_tolerant_parsingcCsx|�ddg�|�ddg�|�ddg�|�ddg�|�d	g�|�d
dg�|�dd
g�|�ddg�|�dg�|�ddg�|�ddg�|�dddgfg�|�ddg�|�ddg�|�dg�|�dg�|�dg�|�dg�|�dg�|�d dd!gfg�|�d"dd#gfg�|�d$d%d#gfg�|�d&dd#gfg�|�d'd%d#gfg�|�d(d)g�dS)*Nrwr��<>)rr��< >)rr��< )rr�z</>�<$>)rr�z</$>)r'�$r�)rr�z</az</ a>)r'z az</ az<a<a>r�a<az</a<a>)r$r�rr�z<az<a foo='bar'z<a foo='barz
<a foo='>'z	<a foo='>z<a$>za$z<a$b>�a$bz<a$b/>r!z<a$b  >z<a$b  />z</a$b>)r$r�rWrErrr�test_starttag_junk_charsYs2z+HTMLParserTestCase.test_starttag_junk_charsc
Cs�|�ddddgfg�d}ddgd�fg}|�||�d}ddgd	�fd
dgd	�fg}|�||�d}d
dgfd
dgfd
dgfd
dgfddgfddgfddgfddgfg}|�||�dS)
Nz<a foo="var"/>r!rj)r��varzj<img width=902 height=250px src="/sites/default/files/images/homepage/foo.jpg" /*what am I doing here*/ />r]))�width�902)�height�250px)r^z,/sites/default/files/images/homepage/foo.jpg)z*whatN)�amN)�iN)�doingN)zhere*Nz9<a / /foo/ / /=/ / /bar/ / /><a / /foo/ / /=/ / /bar/ / >))r�N)�=N)�barNrzD<meta><meta / ><meta // ><meta / / ><meta/><meta /><meta //><meta//>�metarWr�rrr�test_slashes_in_starttagts$���z+HTMLParserTestCase.test_slashes_in_starttagcCs |�ddg�|�ddg�dS)Nz</a/>rlz</a foo="var"/>rWrErrr�test_slashes_in_endtag�sz)HTMLParserTestCase.test_slashes_in_endtagcCro)Nz<!DOCTYPE foo $ >)r.zDOCTYPE foo $ rWrErrr�test_declaration_junk_chars�r*z.HTMLParserTestCase.test_declaration_junk_charscCro)Nz"<!spacer type="block" height="25">)r'zspacer type="block" height="25"rWrErrr�test_illegal_declarations�s�z,HTMLParserTestCase.test_illegal_declarationscCsZd}ddgfdddgfdddgfdddgfdddgfdddgfddgfg}|�||�dS)Nzn<br></label</p><br></div end tmAd-leaderBoard><br></<h4><br></li class="unit"><br></li
						</ul><br></><br>r�br)r$zlabel<rg)r'z<h4)r$�lirWr�rrr�test_invalid_end_tags�s�z(HTMLParserTestCase.test_invalid_end_tagscCs&d}ddgfdddg}|�||�dS)Nz(<b>This</b attr=">"> confuses the parserrrk)r�Thisrm)rz confuses the parserrWr�rrr�test_broken_invalid_end_tag�s�z.HTMLParserTestCase.test_broken_invalid_end_tagcCs�d}dddgfddgfddddgfd	d
ddd
gfdddgfddddg}|�||�d}ddgd�fddgfddddgfd	d
g}|�||�dS)Nz[<div style=""    ><b>The <a href="some_url">rain</a> <br /> in <span>Spain</span></b></div>rrf�r�r~rk)rzThe rj)r��some_url)r�rainrl�rr�r!r�)rz in �span)r�Spain�r$rrmrgz><div style="", foo = "bar" ><b>The <a href="some_url">rain</a>)r���,N�r�r�rWr�rrr�$test_correct_detection_of_start_tags�s4

�
�z7HTMLParserTestCase.test_correct_detection_of_start_tagscCsFddgfddgfdgd�fddd	gfg}|D]
\}}|�||�qdS)
N�a&)rr
za&b)r�abza&b )�rrj�r0rkrza&b;rr
rW�r
rrr�rrr�test_EOF_in_charref�s

��z&HTMLParserTestCase.test_EOF_in_charrefcCs�ddgfddgfddgfddgfddgfd	dgfd
dgfdd
gfddgfddgfddgfddgfddgfddgfg}|D]
\}}|�||�q<dS)Nr�r�z<!---z<!----z<!-----r�z<!------r�z<!----!z<!---!)r'z-!z<!---!>r�z<!--foo)r'r�z<!--foo-z	<!--foo--z
<!--foo--!z<!--<!--r�z	<!--<!--!rWrrrr�test_eof_in_comments�s$��z'HTMLParserTestCase.test_eof_in_commentscCsrddgfddgfddgfddgfd	d
gfddgfd
dgfddgfddgfddgfg
}|D]
\}}|�||�q,dS)Nrr�r�r�z<![)r'�[z	<!DOCTYPE)r.�DOCTYPEz
<!DOCTYPE )r.r�z<!DOCTYPE html)r.zDOCTYPE htmlz<!DOCTYPE html )r.z
DOCTYPE html z<!DOCTYPE html PUBLIC)r.zDOCTYPE html PUBLICz<!DOCTYPE html PUBLIC "foo)r.zDOCTYPE html PUBLIC "fooz6<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "foo)r.z4DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "foorWrrrr�test_eof_in_declarationss ��
�z+HTMLParserTestCase.test_eof_in_declarations)r~r�zx]zx]]cCsn|�d|dd|fg�|jd|dd|fgtdd�d�|�d	|d
dgfd
dd
gfdd|fg�dS)Nz	<![CDATA[r4�CDATA[r'z[CDATA[Trr��<svg><text y="100"><![CDATA[rrr��r��100r�)r
r�rrr�test_eof_in_cdatas
�
�


��z$HTMLParserTestCase.test_eof_in_cdatacCr�)Nz�<!ELEMENT br EMPTY><! not really a comment ><! not a comment either --><! -- close enough --><!><!<-- this was an empty comment><!!! another bogus comment !!!>))r'zELEMENT br EMPTY)r'z not really a comment )r'z not a comment either --)r'z -- close enough --r�)r'z<-- this was an empty comment)r'z!! another bogus comment !!!rWr�rrr�test_bogus_comments s	z&HTMLParserTestCase.test_bogus_commentscCsXd}dddddddgfdd	dd
dgfddd
dgfdddddd
dgfdg}|�||�dS)Nz�<![if !(IE)]>broken condcom<![endif]><![if ! IE]><link href="favicon.tiff"/><![endif]><![if !IE 6]><img src="firefox.png" /><![endif]><![if !ie 6]><b>foo</b><![endif]><![if (!IE)|(lt IE 9)]><img src="mammoth.bmp" /><![endif]>)r4zif !(IE))rzbroken condcom)r4�endif)r4zif ! IEr!�link)r�zfavicon.tiff)r4zif !IE 6r])r^zfirefox.png)r4zif !ie 6rrk)rr�rm)r4zif (!IE)|(lt IE 9))r^zmammoth.bmprWr�rrr�test_broken_condcoms2s(


�z'HTMLParserTestCase.test_broken_condcoms)zjust some plain textz<!-- not a comment -->z&not-an-entity-ref;r�r~z[[I have many brackets]]zI have a > in the middlezI have a ]] in the middlez] ]>z]] >zN
    if (a < b && a > b) {
        printf("[<marquee>How?</marquee>]");
    }
cCsVd|�d�}ddgfdddgfdd|fd	d
g}|�||�|j||tdd�d
�dS)Nrz]]></text></svg>rrr�rr4r�r$r��r$rTrr�r�)r
r�rr�rrr�test_cdata_section_contentTs

�z-HTMLParserTestCase.test_cdata_section_contentc	CsBd}ddddgfdddgfdd	d
ddg	}|j||tdd�d
�dS)Nzb<![CDATA[foo<br>bar]]><svg><text y="100"><![CDATA[foo<br>bar]]></text></svg><![CDATA[foo<br>bar]]>)r'z
[CDATA[foo<br)rzbar]]>rrr�r)r4zCDATA[foo<br>barrrTrr�r�r�rrr�test_cdata_sectionrs
�z%HTMLParserTestCase.test_cdata_sectioncCs8tdd�}|�d�|�|��dddgfddd	g�dS)
NTrHzfoo <a>link</a> bar &amp; baz)rzfoo rrj)rrrl)rz
 bar & baz)rrK�assertEqualr)r
r	rrr�"test_convert_charrefs_dropped_text�s

��z5HTMLParserTestCase.test_convert_charrefs_dropped_text�cpucCs�dd�}d}|d|�|d|�|d|�|d|�|d|�|d	|�|d
|�|d|�|d|�|d
|�dS)NcSs tj��}|�|�|��dSrD)rr	r
rKrL)rPr	rrr�check�s

zBHTMLParserTestCase.test_eof_no_quadratic_complexity.<locals>.checki��r|z<a a=z8</a </a </a </a </a </a </a </a </a </a </a </a </a </a zB</a a=</a a=</a a=</a a=</a a=</a a=</a a=</a a=</a a=</a a=</a a=z<!--<!--<!--<!--zx<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!z&<?<?<?<?<?<?<?<?<?<?<?<?<?<?<?<?<?<?<?z-</$</$</$</$</$</$</$</$</$</$</$</$</$</$</$zQ<![CDATA[<![CDATA[<![CDATA[<![CDATA[<![CDATA[<![CDATA[<![CDATA[<![CDATA[<![CDATA[a;<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctyper)r
r$�nrrr� test_eof_no_quadratic_complexity�sz3HTMLParserTestCase.test_eof_no_quadratic_complexityN)4r6r7r8rXrcrhrirnrqrtr{r�r�r�r�r�subTestsr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r	rrrrrrrr r"�requires_resourcer&rrrrrV�s| 



�








-	)!
"
rVc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#S)$�AttributesTestCasecCs�ddgd�fg}|�d|�|�ddddgfg�|�ddddgfg�|�d	dddgfg�|�d
dddgfg�|�dddd
gfg�|�ddddgfg�|�ddddgfg�|�ddddgfg�|�ddddgfg�dS)Nrrj))rk�v)�cr*)�dr*)�eNz<a b='v' c="v" d=v e>z<a foo==bar>)r�z=barz<a foo =bar>rz<a foo	=bar>z<a foo=bar>)zfoor�u
<a foo =bar>)ufoo r�z<a foo= bar>z<a foo=	bar>z<a foo=bar>)r�zbaru
<a foo= bar>)r�u barrWr�rrr�test_attr_syntax�s�z#AttributesTestCase.test_attr_syntaxcCs�|�dddgd�fg�|�dddddgfg�|�dddd	d
gfg�|�ddddd
gfg�|�ddddgfg�|�ddddgfg�dS)Nz'<a b='xxx
	xxx' c="yyy	
yyy" d='	xyz
'>rrj))rkzxxx
	xxx)r+zyyy	
yyy)r,z	xyz
z
<a b='' c="">)rkr~)r+r~z
<a b=	x c=
y>)rkr�)r+r�u<a b= c= >)rk�)r+� z<e a=rgb(1,2,3)>r-)rjz
rgb(1,2,3)z<a href=mailto:xyz@example.com>)r�zmailto:xyz@example.comrWrErrr�test_attr_values�s&������z#AttributesTestCase.test_attr_valuescCsL|�dddddgfg�|�ddddd	gfg�|�d
dddd	gfg�dS)Nu!<img src=/foo/bar.png alt=中文>rr])r^z/foo/bar.png)�altu中文u+<a title='テスト' href='テスト.html'>rj)r�u	テスト)r�uテスト.htmlu+<a title="テスト" href="テスト.html">rWrErrr�test_attr_nonascii�s$������z%AttributesTestCase.test_attr_nonasciicC�|�ddddgfg�dS)Nz!<a b='&amp;&gt;&lt;&quot;&apos;'>rrj)rkz&><"'rWrErrr�test_attr_entity_replacement���z/AttributesTestCase.test_attr_entity_replacementcCs|�dddgd�fg�dS)Nz<a a.b='v' c:d=v e-f=v>rrj))za.br*)zc:dr*)ze-fr*rWrErrr�test_attr_funky_names�s�z(AttributesTestCase.test_attr_funky_namescCr4)Nz0<html foo='&euro;&amp;&#97;&#x61;&unsupported;'>rr)r�u€&aa&unsupported;rWrErrr�test_entityrefs_in_attributes�r6z0AttributesTestCase.test_entityrefs_in_attributescCs.|�ddddgfdddgfdddgfg�dS)	Nz<a $><b $=%><c \=/>rrj)r�Nrk)r��%r+)�\r�rWrErrr�test_attr_funky_names2�s


��z)AttributesTestCase.test_attr_funky_names2cCs\dD])}|�d|dddgfg�|�d|dddgfg�|�d|dddgfg�qdS)N)�&z&amp;z&#38;z&#x26;z
<a href="%s">rrj)r�r<z
<a href='%s'>z<a href=%s>rW)r
r[rrr� test_entities_in_attribute_value�s
�
�
��z3AttributesTestCase.test_entities_in_attribute_valuecCsPd}dddgfdddddgfddddd	gfd
ddddgfddg}|�||�dS)
Nz�<a href=test'style='color:red;bad1'>test - bad1</a><a href=test'+style='color:red;ba2'>test - bad2</a><a href=test'&nbsp;style='color:red;bad3'>test - bad3</a><a href = test'&nbsp;style='color:red;bad4'  >test - bad4</a>rrj)r�ztest'style='color:red;bad1')rztest - bad1rl)r�ztest'+style='color:red;ba2')rztest - bad2)r�utest' style='color:red;bad3')rztest - bad3)r�utest' style='color:red;bad4')rztest - bad4rWr�rrr�test_malformed_attributes�s �



�z,AttributesTestCase.test_malformed_attributescCsH|�dddgfddddgfdg�|�d	ddgfdddd
gfdg�dS)Nz<x><y z=""o"" /></x>rr�r!r�)r�r~)zo""N)r$r�z<x><y z="""" /></x>)z""NrWrErrr�"test_malformed_adjacent_attributess����z5AttributesTestCase.test_malformed_adjacent_attributescCs4|�dddddgfg�|�dddddgfg�dS)	Nz<a width="100%"cellspacing=0>rrj�r�z100%��cellspacing�0z<a id="foo"class="bar">)�idr���classr�rWrErrr�test_adjacent_attributess����z+AttributesTestCase.test_adjacent_attributescCr4)Nz<a v=>rrj)r*r~rWrErrr�test_missing_attribute_value&s�z/AttributesTestCase.test_missing_attribute_valuecCr4)Nz-<a href=javascript:popup('/popup/help.html')>rrj)r�z$javascript:popup('/popup/help.html')rWrErrr�test_javascript_attribute_value*s
��z2AttributesTestCase.test_javascript_attribute_valuecCs|�ddddgfddg�dS)Nz-<a href='http://www.example.org/">;'>spam</a>rrj)r�zhttp://www.example.org/">;)r�spamrlrWrErrr�test_end_tag_in_attribute_value/s���z2AttributesTestCase.test_end_tag_in_attribute_valuecCs�d}ddgfddddgfddgd�fdd	gfdd
dgfddd
gfddddgfdddgfdddddddgfdddgfddddg}|�||�dS)Nz�<html><body bgcolor=d0ca90 text='181008'><table cellspacing=0 cellpadding=1 width=100% ><tr><td align=left><font size=-1>- <a href=/rabota/><span class=en> software-and-i</span></a>- <a href='/1/'><span class=en> library</span></a></table>rr�body)�bgcolor�d0ca90)r��181008�table)rA)�cellpaddingr�r@�tr�td)�align�left�font)�sizez-1)rz- rj)r�z/rabota/r)rF�en)rz software-and-irrl)r�z/1/)rz library)r$rPrWr�rrr�test_with_unquoted_attributes6s"�

�z0AttributesTestCase.test_with_unquoted_attributescCs�d}dddgfddddgfddddgfddgd	�fdddd
gfddddgfddd
dgfddddgfddddgfg	}|�||�dS)Nz�<div class=bar,baz=asd><div class="bar",baz="asd"><div class=bar, baz=asd,><div class="bar", baz="asd",><div class="bar",><div class=,bar baz=,asd><div class=,"bar" baz=,"asd"><div ,class=bar ,baz=asd><div class,="bar" baz,="asd">rrf)rFzbar,baz=asdrE)z,baz�asd)rFzbar,)�bazzasd,)rEr)r[rZrr)rFz,bar)r[z,asd)rFz,"bar")r[z,"asd")z,classr�)zclass,r�)zbaz,rZrWr�rrr�test_comma_between_attributesNs
�z0AttributesTestCase.test_comma_between_attributescCr4)Nz<form action=bogus|&#()value>r�form)�actionzbogus|&#()valuerWrErrr�-test_weird_chars_in_unquoted_attribute_valuesjs
�
�z@AttributesTestCase.test_weird_chars_in_unquoted_attribute_valuesN)r6r7r8r.r1r3r5r7r8r;r=r>r?rGrHrIrKrYr\r_rrrrr)�s$
	r)�__main__)�__doc__�html.parserrrN�unittest�testrr�r�r	r
rr:r=rC�TestCaserFrVr)r6�mainrrrr�<module>s2�	@&K�

Youez - 2016 - github.com/yon3zu
LinuXploit