403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.217.130
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_htmlparser.cpython-36.opt-1.pyc
3

�w2_��@s�dZddlZddlZddlZGdd�dejj�ZGdd�de�ZGdd�de�Z	Gd	d
�d
ej
�ZGdd�de�ZGd
d�de�Z
edkr�ej�dS)zTests for HTMLParser.py.�Nc@sleZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�EventCollectorcOs*g|_|jj|_tjjj|f|�|�dS)N)�events�append�html�parser�
HTMLParser�__init__)�self�args�kw�r�9/opt/alt/python36/lib64/python3.6/test/test_htmlparser.pyr
s
zEventCollector.__init__cCsng}d}xZ|jD]P}|d}||ko.dknrRd|dd|df|d<n
|j|�|}qW||_|S)Nr�data����r)rr)r	�LZprevtypeZevent�typerrr
�
get_eventss
zEventCollector.get_eventscCs|jd||f�dS)N�starttag)r)r	�tag�attrsrrr
�handle_starttag szEventCollector.handle_starttagcCs|jd||f�dS)N�startendtag)r)r	rrrrr
�handle_startendtag#sz!EventCollector.handle_startendtagcCs|jd|f�dS)N�endtag)r)r	rrrr
�
handle_endtag&szEventCollector.handle_endtagcCs|jd|f�dS)N�comment)r)r	rrrr
�handle_comment+szEventCollector.handle_commentcCs|jd|f�dS)N�charref)r)r	rrrr
�handle_charref.szEventCollector.handle_charrefcCs|jd|f�dS)Nr)r)r	rrrr
�handle_data1szEventCollector.handle_datacCs|jd|f�dS)N�decl)r)r	rrrr
�handle_decl4szEventCollector.handle_declcCs|jd|f�dS)N�	entityref)r)r	rrrr
�handle_entityref7szEventCollector.handle_entityrefcCs|jd|f�dS)N�pi)r)r	rrrr
�	handle_pi:szEventCollector.handle_picCs|jd|f�dS)Nzunknown decl)r)r	r!rrr
�unknown_decl=szEventCollector.unknown_declN)�__name__�
__module__�__qualname__rrrrrrrr r"r$r&r'rrrr
rsrc@seZdZdd�ZdS)�EventCollectorExtracCs$tj|||�|jd|j�f�dS)N�
starttag_text)rrrZget_starttag_text)r	rrrrr
rCsz#EventCollectorExtra.handle_starttagN)r(r)r*rrrrr
r+Asr+c@seZdZdd�Zdd�ZdS)�EventCollectorCharrefscCs|jd�dS)Nz6This should never be called with convert_charrefs=True)�fail)r	rrrr
rJsz%EventCollectorCharrefs.handle_charrefcCs|jd�dS)Nz6This should never be called with convert_charrefs=True)r.)r	rrrr
r$Msz'EventCollectorCharrefs.handle_entityrefN)r(r)r*rr$rrrr
r-Hsr-c@s&eZdZdd�Zddd�Zdd�ZdS)	�TestCaseBasecCs
tdd�S)NF)�convert_charrefs)r)r	rrr
�
get_collectorSszTestCaseBase.get_collectorNcCsv|dkr|j�}|}x|D]}|j|�qW|j�|j�}||krr|jdt|�dtj|�dtj|��dS)Nz-received events did not match expected eventsz	
Source:
z
Expected:
z
Received:
z6received events did not match expected events
Source:
)r1�feed�closerr.�repr�pprintZpformat)r	�sourceZexpected_events�	collectorr�srrrr
�
_run_checkVs
zTestCaseBase._run_checkcCs|j||tdd��dS)NF)r0)r9r+)r	r6rrrr
�_run_check_extradszTestCaseBase._run_check_extra)N)r(r)r*r1r9r:rrrr
r/Qs
r/c@seZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCS)D�HTMLParserTestCasecCs |jddg�|jddg�dS)Nz<?processing instruction>r%�processing instructionz<?processing instruction ?>�processing instruction ?)r%r<)r%r=)r9)r	rrr
� test_processing_instruction_onlyksz3HTMLParserTestCase.test_processing_instruction_onlycCsB|jddddddgfdddddddddgfd d!d"d#d$d%d&g�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!�DOCTYPE html PUBLIC 'foo'rrr#�entityr�32r�4comment1a
-></foo><bar>&lt;<?pi?></foo<bar
comment1b�img�src�Bar�ismap�sample
text
�x201C�comment2a-- --comment2br)rr?)r!r@)rr?)r#rA)rrB)rr?)rrC)rr?)rErF)rGN)rrH)rrI)rr?)rrJ)rr?)rr)rr?)r9)r	rrr
�test_simple_htmlss&z#HTMLParserTestCase.test_simple_htmlcCs6|jdddgfd	d
g�|jdgddgfddg�dS)
Nz
<p>&#bad;</p>r�pr�&#bad;rz<div>&#bad;</div>�div)rrM)rrL)rrM)rrN)r9)r	rrr
�test_malformatted_charref�sz,HTMLParserTestCase.test_malformatted_charrefcCs|jdddg�dS)Nz&entityref foor#r� foo)r#r#)rrP)r9)r	rrr
�test_unclosed_entityref�sz*HTMLParserTestCase.test_unclosed_entityrefcCs$|jdddgfddgfddg�dS)Nz<a><b></a></b>r�a�br)rrR)rrS)r9)r	rrr
�test_bad_nesting�s
z#HTMLParserTestCase.test_bad_nestingcCs|jddg�dS)N�#this text & contains & ampersands &r)rrU)r9)r	rrr
�test_bare_ampersands�sz'HTMLParserTestCase.test_bare_ampersandscCs|jddg�dS)N�.this < text > contains < bare>pointy< bracketsr)rrW)r9)r	rrr
�test_bare_pointy_brackets�sz,HTMLParserTestCase.test_bare_pointy_bracketscCs0|jddddgfg�|jdddd	gfg�dS)
Nz	<a b='<'>rrRrS�<z	<a b='>'>�>)rSrY)rSrZ)r9)r	rrr
�test_starttag_end_boundary�sz-HTMLParserTestCase.test_starttag_end_boundarycCs�ddd*gfg}|jdg|�|jddg|�|jdd	g|�|jd
dg|�|jdd
g|�|jddg|�ddd+gfg}|jdg|�|jddg|�|jddg|�|jd
dg|�|jdd
g|�|jddg|�d,g}|jddg|�|jddg|�|jddg|�|jddg|�|jdd g|�|jd!d"g|�|jd#d$g|�|jd%d&g|�|jd'd(g|�|jd)dg|�|jddg|�dS)-NrrRrSrYz	<a b='<'>z<a zb='<'>z<a bz='<'>z<a b=z'<'>z<a b='<z'>z<a b='<'rZz	<a b='>'>zb='>'>z='>'>z'>'>z<a b='>z<a b='>'r�abc�z
<!--abc-->z	!--abc-->z<!z--abc-->z<!-z-abc-->z<!--zabc-->z<!--azbc-->z<!--abzc-->z<!--abcz-->z<!--abc-z->z	<!--abc--)rSrY)rSrZ)rr\)r9)r	�outputrrr
�test_buffer_artefacts�s4z(HTMLParserTestCase.test_buffer_artefactsc
CsDddddddddd	d
g
}x&|D]}|jd|dd
|fg�qWdS)NZHTMLzOHTML 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!zDOCTYPE )r9)r	ZdtdsZdtdrrr
�test_valid_doctypes�s

z&HTMLParserTestCase.test_valid_doctypescCsN|jdddgfg�|jdddgfdg�|jdddgfdddgfd
g�dS)Nz<p/>rrLz<p></p>rrz<p><img src='foo' /></p>rDrE�foo)rrL)rEra)rrL)r9)r	rrr
�test_startendtag�s
z#HTMLParserTestCase.test_startendtagcCs&d}|j|ddd	d
gfd|fg�dS)Nz <foo:bar   
   one="1"	two=2   >rzfoo:bar�one�1�two�2r,)rcrd)rerf)r:)r	r8rrr
�test_get_starttag_textsz)HTMLParserTestCase.test_get_starttag_textcCs�ddddddddd	d
dg}dd
ddddg}xP|D]H}xB|D]:}|j�}dj||d�}|j|d|gfd|fd|fg�q:Wq0WdS)Nz*<!-- not a comment --> &not-an-entity-ref;z<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;
// -->
zfoo = "</sty" + "le>";u<!-- ☃ -->�script�styleZSCRIPTZSTYLEZScriptZStylez <{element}>{content}</{element}>)�element�contentrrr)�lower�formatr9)r	�contents�elementsrkrj�
element_lowerr8rrr
�test_cdata_content	s(

z%HTMLParserTestCase.test_cdata_contentcCsjGdd�dt�}d}xPdD]H}|j�j�}d
j||d�}|j|d|gfd
|fd|fg|dd�d�qWdS)Nc@seZdZdd�ZdS)zBHTMLParserTestCase.test_cdata_with_closing_tags.<locals>.CollectorcSs|jS)N)r)r	rrr
r.szMHTMLParserTestCase.test_cdata_with_closing_tags.<locals>.Collector.get_eventsN)r(r)r*rrrrr
�	Collector-srrz�<!-- not a comment --> &not-an-entity-ref;
                  <a href="" /> </p><p> <span></span></style>
                  '</script' + '>'� script�script � script �
script�script
�
script
z<script>{content}</{element}>)rjrkrrrF)r0)r7)rsrtrurvrwrx)rrl�striprmr9)r	rrrkrjrpr8rrr
�test_cdata_with_closing_tags(sz/HTMLParserTestCase.test_cdata_with_closing_tagscCs&d}d
ddd
dddg}|j||�dS)Nz�<!-- I'm a valid comment --><!--me too!--><!------><!----><!----I have many hyphens----><!-- I have a > in the middle --><!-- and I have -- in the middle! -->r� I'm a valid comment �me too!�--r]�--I have many hyphens--� I have a > in the middle � and I have -- in the middle! )rr{)rr|)rr})rr])rr~)rr)rr�)r9)r	r�expectedrrr
�
test_comments>sz HTMLParserTestCase.test_commentscCsd}dddg}|j||�dS)	Nzs<!--[if IE & !(lte IE 8)]>aren't<![endif]--><!--[if IE 8]>condcoms<![endif]--><!--[if lte IE 7]>pretty?<![endif]-->r�%[if IE & !(lte IE 8)]>aren't<![endif]�f IE 8]>condcoms<![endif]�[if lte IE 7]>pretty?<![endif])rr�)rr�)rr�)r9)r	rr�rrr
�
test_condcomsOs
z HTMLParserTestCase.test_condcomscCs^dd�}|j|�j�ddddddg}d	d
d!gfd"d#g}x$|D]}|jdj|�||�d�q>Wd$d	d
d%d&d'gfd(d)d*g}x$|D]}|jdj|�||�d�q~Wx`|D]X}dj|gd�}d+d	dgfd
|fd,d-d	dgfd
|fd.d/g	}|jdj||�||�d�q�Wd}x@tdt|��D].}|j|d|�d
|d|�fg|�d��qW|jd d0g|�d�dS)1NcSst�S)N)r-rrrr
�<lambda>Zsz:HTMLParserTestCase.test_convert_charrefs.<locals>.<lambda>z&quot;z&#34;z&#x22;z&quotz&#34z&#x22rrR�href�foo"zarr�a"zrz<a href="foo{0}zar">a{0}z</a>)r7�"�x�y�"X�z�X"z*{0}<a x="{0}" y="{0}X" z="X{0}">{0}</a>{0}�X�rhriz/{1}<script>{0}</script>{1}<style>{0}</style>{1}z&quo &# &#xr�no charrefs here)r�r�)rr�)rrR)rr�)r�r�)r�r�)r�r�)rr�)rrR)rr�)rr�)rrh)rr�)rri)rr�)rr�)Z
assertTruer0r9rm�join�range�len)r	r7Zcharrefsr�r�textrr�rrr
�test_convert_charrefsXs>





z(HTMLParserTestCase.test_convert_charrefscCs2|jddddgfddddd
dgfddddg	�dS)NzF<html <html>te>>xt&a<<bc</a></html>
<img src="URL><//img></html</html>rr�<htmlr�te>>xtr#rRrYzbc<r�
<img src="URL>r�/img�html<)r�N)rr�)r#rR)rrY)rRN)rr)rr�)rr�)rr�)r9)r	rrr
�test_tolerant_parsing�s

z(HTMLParserTestCase.test_tolerant_parsingcCs|jdg�|jddg�|jddg�|jddg�|jdd	d
gfg�|jddg�|jd
dg�|jdd g�|jdd!g�|jdd"g�|jdd#g�|jdd$g�|jdd	dgfg�|jdd	dgfg�|jdddgfg�|jdd	dgfg�|jdddgfg�dS)%Nz</>z</$>r�$�</r�</az<a<a>r�a<az</a<a>r�<!�<a�<a foo='bar'�<a foo='bar�
<a foo='>'�	<a foo='>z<a$>za$z<a$b>za$bz<a$b/>rz<a$b  >z<a$b  />)rr�)rr�)rr�)rr�)rr�)rr�)rr�)rr�)rr�)rr�)r9)r	rrr
�test_starttag_junk_chars�s"z+HTMLParserTestCase.test_starttag_junk_charscCs�|jddddgfg�d}ddddddddd d!gfg}|j||�d}ddd"d#d$gfddd%d&d'gfg}|j||�d}ddgfddgfddgfddgfddgfddgfddgfddgfg}|j||�dS)(Nz<a foo="var"/>rrRra�varzj<img width=902 height=250px src="/sites/default/files/images/homepage/foo.jpg" /*what am I doing here*/ />rD�width�902�height�250pxrE�,/sites/default/files/images/homepage/foo.jpg�*what�am�i�doing�here*z9<a / /foo/ / /=/ / /bar/ / /><a / /foo/ / /=/ / /bar/ / >�=�barrzD<meta><meta / ><meta // ><meta / / ><meta/><meta /><meta //><meta//>�meta)rar�)r�r�)r�r�)rEr�)r�N)r�N)r�N)r�N)r�N)raN)r�N)r�N)raN)r�N)r�N)r9)r	rr�rrr
�test_slashes_in_starttag�s$z+HTMLParserTestCase.test_slashes_in_starttagcCs|jddg�dS)Nz<!DOCTYPE foo $ >r!�DOCTYPE foo $ )r!r�)r9)r	rrr
�test_declaration_junk_chars�sz.HTMLParserTestCase.test_declaration_junk_charscCs|jddg�dS)Nz"<!spacer type="block" height="25">r�spacer type="block" height="25")rr�)r9)r	rrr
�test_illegal_declarations�sz,HTMLParserTestCase.test_illegal_declarationscCs�d}ddgfddd#d$gfdd	d%d&d'gfddgfddd(gfddd)gfd*ddd+gfddd,gfd-d.d/d0ddd1gfddd2gfd3d4d5d6g}|j||�dS)7Nz�<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>rrZbody�bgcolor�d0ca90r��181008�table�cellspacing�0�cellpaddingrdr��100%ZtrZtd�align�leftZfont�size�-1r�- rRr��/rabota/�span�class�en� software-and-ir�/1/� library)r�r�)r�r�)r�r�)r�rd)r�r�)r�r�)r�r�)rr�)r�r�)r�r�)rr�)rr�)rrR)rr�)r�r�)r�r�)rr�)rr�)rrR)rr�)r9)r	rr�rrr
�test_with_unquoted_attributes�s



z0HTMLParserTestCase.test_with_unquoted_attributescCs|jdddd	d
dgfg�dS)Nz7<form action="/xxx.php?a=1&amp;b=2&amp", method="post">r�form�action�/xxx.php?a=1&b=2&�,�method�post)r�r�)r�N)r�r�)r9)r	rrr
�test_comma_between_attributes�sz0HTMLParserTestCase.test_comma_between_attributescCs|jddddgfg�dS)Nz<form action=bogus|&#()value>rr�r��bogus|&#()value)r�r�)r9)r	rrr
�-test_weird_chars_in_unquoted_attribute_values�sz@HTMLParserTestCase.test_weird_chars_in_unquoted_attribute_valuescCsZd}ddgfd
ddgfdddgfdddgfd
ddgfdddgfddgfg}|j||�dS)Nzn<br></label</p><br></div end tmAd-leaderBoard><br></<h4><br></li class="unit"><br></li
						</ul><br></><br>r�brr�label<rNr�<h4�li)rr�)rrN)rr�)rr�)rr�)r9)r	rr�rrr
�test_invalid_end_tags�sz(HTMLParserTestCase.test_invalid_end_tagscCs&d}ddgfdd	d
g}|j||�dS)Nz(<b>This</b attr=">"> confuses the parserrrSr�Thisr�"> confuses the parser)rr�)rrS)rr�)r9)r	rr�rrr
�test_broken_invalid_end_tagsz.HTMLParserTestCase.test_broken_invalid_end_tagcCs�d}dddgfddgfddd	dgfdddddgfdddgfdd d!d"g}|j||�d}ddd#d$d%gfddgfd&dd	d'gfd(d)g}|j||�dS)*Nz[<div style=""    ><b>The <a href="some_url">rain</a> <br /> in <span>Spain</span></b></div>rrNrir]rSr�The rRr��some_url�rainr� rr�� in r��Spainz><div style="", foo = "bar" ><b>The <a href="some_url">rain</a>r�rar�)rir])rr�)r�r�)rr�)rrR)rr�)rr�)rr�)rr�)rrS)rrN)rir])r�N)rar�)rr�)r�r�)rr�)rrR)r9)r	rr�rrr
�$test_correct_detection_of_start_tagss0


z7HTMLParserTestCase.test_correct_detection_of_start_tagscCsLddgfddgfdd
ddgfd
ddgfg}x|D]\}}|j||�q0WdS)N�a&rza&b�abza&b rRr#rSr�za&b;)rr�)rr�)rrR)r#rS)rr�)rrR)r#rS)r9)r	rrr�rrr
�test_EOF_in_charref2sz&HTMLParserTestCase.test_EOF_in_charrefcCsHddlm}|j�}|jt�� d}|j|j|�||��WdQRXdS)Nr)�unescapez%&quot;&#34;&#x22;&quot&#34&#x22&#bad;)rr�r1ZassertWarns�DeprecationWarning�assertEqual)r	r�rLr8rrr
�test_unescape_method@s
z'HTMLParserTestCase.test_unescape_methodcCs$d}d	d
ddd
dg}|j||�dS)Nz�<! not really a comment ><! not a comment either --><! -- close enough --><!><!<-- this was an empty comment><!!! another bogus comment !!!>r� not really a comment � not a comment either --� -- close enough --r]�<-- this was an empty comment�!! another bogus comment !!!)rr�)rr�)rr�)rr])rr�)rr�)r9)r	rr�rrr
�test_broken_commentsGsz'HTMLParserTestCase.test_broken_commentscCsXd}dddddd	dgfdddd
dgfdd ddgfd!d"d#d$dd
d%gfd&g}|j||�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]>�unknown decl�if !(IE)r�broken condcom�endif�if ! IEr�linkr��favicon.tiff�if !IE 6rDrE�firefox.png�if !ie 6rrSrar�if (!IE)|(lt IE 9)�mammoth.bmp)r�r�)rr�)r�r�)r�r�)r�r�)r�r�)r�r�)rEr�)r�r�)r�r)rra)rrS)r�r�)r�r)rEr)r�r�)r9)r	rr�rrr
�test_broken_condcomsWs&


z'HTMLParserTestCase.test_broken_condcomscCs8tdd�}|jd�|j|j�dddgfdd
dg�dS)NT)r0zfoo <a>link</a> bar &amp; bazr�foo rrRr�r�
 bar & baz)rr)rr�)rrR)rr)rr2r�r)r	rrrr
�"test_convert_charrefs_dropped_textxs

z5HTMLParserTestCase.test_convert_charrefs_dropped_textN)$r(r)r*r>rKrOrQrTrVrXr[r_r`rbrgrqrzr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr
r;isB 
	)
!!r;c@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�AttributesTestCasecCsHdddd
ddgfg}|jd|�|jd	|�|jd
|�|jd|�dS)NrrRrS�v�c�d�ez<a b='v' c="v" d=v e>z<a  b = 'v' c = "v" d = v e>z<a
b
=
'v'
c
=
"v"
d
=
v
e>z<a	b	=	'v'	c	=	"v"	d	=	v	e>)rSr)r	r)r
r)rN)r9)r	r^rrr
�test_attr_syntax�s
z#AttributesTestCase.test_attr_syntaxcCsb|jddddddgfg�|jd
ddddgfg�|jddd
dgfg�|jddddgfg�dS)Nz'<a b='xxx
	xxx' c="yyy	
yyy" d='	xyz
'>rrRrS�xxx
	xxxr	�yyy	
yyyr
�	xyz
z
<a b='' c="">r]z<e a=rgb(1,2,3)>r�
rgb(1,2,3)z<a href=mailto:xyz@example.com>r��mailto:xyz@example.com)rSr
)r	r)r
r)rSr])r	r])rRr)r�r)r9)r	rrr
�test_attr_values�sz#AttributesTestCase.test_attr_valuescCsL|jdddddgfg�|jddd	ddgfg�|jddd	ddgfg�dS)Nu!<img src=/foo/bar.png alt=中文>rrDrE�/foo/bar.png�alt�中文u+<a title='テスト' href='テスト.html'>rR�title�	テストr��テスト.htmlu+<a title="テスト" href="テスト.html">)rEr)rr)rr)r�r)rr)r�r)r9)r	rrr
�test_attr_nonascii�sz%AttributesTestCase.test_attr_nonasciicCs|jddddgfg�dS)Nz!<a b='&amp;&gt;&lt;&quot;&apos;'>rrRrS�&><"')rSr)r9)r	rrr
�test_attr_entity_replacement�sz/AttributesTestCase.test_attr_entity_replacementcCs|jddddd	d
gfg�dS)Nz<a a.b='v' c:d=v e-f=v>rrR�a.br�c:d�e-f)rr)rr)rr)r9)r	rrr
�test_attr_funky_names�sz(AttributesTestCase.test_attr_funky_namescCs|jddddgfg�dS)Nz0<html foo='&euro;&amp;&#97;&#x61;&unsupported;'>rrra�€&aa&unsupported;)rar )r9)r	rrr
�test_entityrefs_in_attributes�sz0AttributesTestCase.test_entityrefs_in_attributescCs.|jdddd
gfdddgfdddgfg�dS)
Nz<a $><b $=%><c \=/>rrRr�rS�%r	�\�/)r�N)r�r")r#r$)r9)r	rrr
�test_attr_funky_names2�s


z)AttributesTestCase.test_attr_funky_names2cCs`xZdD]R}|jd|dddgfg�|jd	|ddd
gfg�|jd
|dddgfg�qWdS)N�&�&amp;�&#38;�&#x26;z
<a href="%s">rrRr�z
<a href='%s'>z<a href=%s>)r&r'r(r))r�r&)r�r&)r�r&)r9)r	rArrr
� test_entities_in_attribute_value�s



z3AttributesTestCase.test_entities_in_attribute_valuec
CsPd}dddgfdddddgfdddddgfdddddgfddg}|j||�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>rrRr��test'style='color:red;bad1'r�test - bad1r�test'+style='color:red;ba2'�test - bad2�test' style='color:red;bad3'�test - bad3�test' style='color:red;bad4'�test - bad4)r�r+)rr,)rrR)r�r-)rr.)rrR)r�r/)rr0)rrR)r�r1)rr2)rrR)r9)r	rr�rrr
�test_malformed_attributes�s



z,AttributesTestCase.test_malformed_attributescCsH|jdddgfdddd
gfdg�|jd
ddgfddddgfdg�dS)Nz<x><y z=""o"" /></x>rr�rr�r�r]�o""rz<x><y z="""" /></x>�"")r�r])r4N)rr�)r�r])r5N)rr�)r9)r	rrr
�"test_malformed_adjacent_attributes�sz5AttributesTestCase.test_malformed_adjacent_attributescCs4|jdddd
dgfg�|jdddddgfg�dS)Nz<a width="100%"cellspacing=0>rrRr��100%r�r�z<a id="foo"class="bar">�idrar�r�)r�r7)r�r�)r8ra)r�r�)r9)r	rrr
�test_adjacent_attributes�sz+AttributesTestCase.test_adjacent_attributescCs|jddddgfg�dS)Nz<a v=>rrRrr])rr])r9)r	rrr
�test_missing_attribute_value�sz/AttributesTestCase.test_missing_attribute_valuecCs|jddddgfg�dS)Nz-<a href=javascript:popup('/popup/help.html')>rrRr��$javascript:popup('/popup/help.html'))r�r;)r9)r	rrr
�test_javascript_attribute_value�sz2AttributesTestCase.test_javascript_attribute_valuecCs|jdddd	gfd
dg�dS)Nz-<a href='http://www.example.org/">;'>spam</a>rrRr��http://www.example.org/">;r�spamr)r�r=)rr>)rrR)r9)r	rrr
�test_end_tag_in_attribute_valuesz2AttributesTestCase.test_end_tag_in_attribute_valueN)r(r)r*rrrrrr!r%r*r3r6r9r:r<r?rrrr
r�s	
	r�__main__)�__doc__Zhtml.parserrr5Zunittestrrrr+r-ZTestCaser/r;rr(�mainrrrr
�<module>s 9	 

Youez - 2016 - github.com/yon3zu
LinuXploit