- GRAYBYTE UNDETECTABLE CODES -

403Webshell
Server IP : 184.154.167.98  /  Your IP : 3.143.235.140
Web Server : Apache
System : Linux pink.dnsnetservice.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
User : puertode ( 1767)
PHP Version : 8.2.26
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3.6/site-packages/html5lib/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.6/site-packages/html5lib/__pycache__/html5parser.cpython-36.pyc
3

B;�W���@sFddlmZmZmZddlmZmZmZddlZyddl	m
Z
Wn ek
r`ddlm
Z
YnXddl
mZddl
mZddl
mZdd	lmZdd
l
mZddlmZmZmZmZmZmZmZmZmZmZmZm Z!m"Z"m#Z#m$Z$m%Z%d!dd�Z&d"dd�Z'dd�Z(Gdd�de)�Z*ej+dd��Z,dd�Z-d#dd�Z.Gdd �d e/�Z0dS)$�)�absolute_import�division�unicode_literals)�with_metaclass�viewkeys�PY3N)�OrderedDict�)�_inputstream)�
_tokenizer)�treebuilders)�Marker)�_utils)�spaceCharacters�asciiUpper2Lower�specialElements�headingElements�
cdataElements�rcdataElements�
tokenTypes�
tagTokenTypes�
namespaces�htmlIntegrationPointElements�"mathmlTextIntegrationPointElements�adjustForeignAttributes�adjustMathMLAttributes�adjustSVGAttributes�E�ReparseException�etreeTcKs$tj|�}t||d�}|j|f|�S)z.Parse a string or file-like object into a tree)�namespaceHTMLElements)r�getTreeBuilder�
HTMLParser�parse)�doc�treebuilderr �kwargs�tb�p�r)�!/usr/lib/python3.6/html5parser.pyr#s
r#�divcKs,tj|�}t||d�}|j|fd|i|��S)N)r �	container)rr!r"�
parseFragment)r$r,r%r r&r'r(r)r)r*r-&s
r-csG�fdd�dt�}|S)NcseZdZ�fdd�ZdS)z-method_decorator_metaclass.<locals>.DecoratedcsBx0|j�D]$\}}t|tj�r&�|�}|||<q
Wtj||||�S)N)�items�
isinstance�types�FunctionType�type�__new__)�metaZ	classname�basesZ	classDictZ
attributeNameZ	attribute)�functionr)r*r3.s
z5method_decorator_metaclass.<locals>.Decorated.__new__N)�__name__�
__module__�__qualname__r3r))r6r)r*�	Decorated-sr:)r2)r6r:r))r6r*�method_decorator_metaclass,sr;c@s�eZdZdZd+dd�Zd,dd	�Zd
d�Zedd
��Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zd-dd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�ZdS).r"zZHTML parser. Generates a tree structure from a stream of (possibly
        malformed) HTMLNFTcsL|�_|dkrtjd�}||��_g�_t�fdd�t|�j�D���_dS)a
        strict - raise an exception when a parse error is encountered

        tree - a treebuilder class controlling the type of tree that will be
        returned. Built in treebuilders can be accessed through
        html5lib.treebuilders.getTreeBuilder(treeType)
        Nrcs g|]\}}||��j�f�qSr))�tree)�.0�name�cls)�selfr)r*�
<listcomp>Msz'HTMLParser.__init__.<locals>.<listcomp>)	�strictrr!r<�errors�dict�	getPhasesr.�phases)r@r<rBr �debugr))r@r*�__init__<s


zHTMLParser.__init__r+cKsh||_||_||_tj|fd|i|��|_|j�y|j�Wn$tk
rb|j�|j�YnXdS)N�parser)	�
innerHTMLModer,�	scriptingrZ
HTMLTokenizer�	tokenizer�reset�mainLoopr)r@�stream�	innerHTMLr,rKr&r)r)r*�_parsePszHTMLParser._parsecCs�|jj�d|_g|_g|_d|_|jr�|jj�|_	|j	t
krL|jj|j_
n0|j	tkrd|jj|j_
n|j	dkr||jj|j_
n|jd|_|jj�|j�nd|_	|jd|_d|_d|_d|_dS)NFz	no quirks�	plaintext�
beforeHtml�initialT)r<rM�
firstStartTagrC�log�
compatModerJr,�lowerrPrrL�rcdataState�stater�rawtextState�plaintextStaterF�phase�insertHtmlElement�resetInsertionModeZ	lastPhaseZbeforeRCDataPhase�
framesetOK)r@r)r)r*rM^s*





zHTMLParser.resetcCst|d�sdS|jjjdjS)z�The name of the character encoding
        that was used to decode the input stream,
        or :obj:`None` if that is not determined yet.

        rLNr)�hasattrrLrO�charEncodingr>)r@r)r)r*�documentEncoding�s
zHTMLParser.documentEncodingcCsJ|jdkr6|jtdkr6d|jko4|jdjt�dkS|j|jftkSdS)Nzannotation-xml�mathml�encoding�	text/html�application/xhtml+xml)rfrg)r>�	namespacer�
attributes�	translaterr)r@�elementr)r)r*�isHTMLIntegrationPoint�s


z!HTMLParser.isHTMLIntegrationPointcCs|j|jftkS)N)rhr>r)r@rkr)r)r*�isMathMLTextIntegrationPoint�sz'HTMLParser.isMathMLTextIntegrationPointcCsztd}td}td}td}td}td}td}�x�|j�D�]�}d}	|}
�x�|
dk	�r|
}	|jjrx|jjdnd}|r�|jnd}|r�|jnd}
|
d	}||kr�|j|
d
|
jdi��d}
qVt|jj�dk�sl||jj	k�sl|j
|��r ||k�r|d
tddg�k�sl|||fk�sl|tdk�rP|
dk�rP||k�rP|d
dk�sl|j
|��rt||||fk�rt|j}n
|jd}||k�r�|j|
�}
qV||k�r�|j|
�}
qV||k�r�|j|
�}
qV||k�r�|j|
�}
qV||k�r�|j|
�}
qV||krV|j|
�}
qVW||krD|	drD|	drD|jdd
|	d
i�qDWd}g}x8|�rt|j|j�|jj�}|�r>|j|k�s>t��q>WdS)N�
CharactersZSpaceCharacters�StartTag�EndTag�CommentZDoctype�
ParseErrorr	r2�data�datavarsrr>ZmglyphZ
malignmarkrdzannotation-xml�svg�inForeignContent�selfClosing�selfClosingAcknowledgedz&non-void-element-with-trailing-solidusT���)r�normalizedTokensr<�openElementsrhr>�
parseError�get�len�defaultNamespacerm�	frozensetrrlr]rF�processCharacters�processSpaceCharacters�processStartTag�
processEndTag�processComment�processDoctype�append�
processEOF�AssertionError)r@ZCharactersTokenZSpaceCharactersTokenZ
StartTagTokenZEndTagTokenZCommentTokenZDoctypeTokenZParseErrorToken�tokenZ
prev_token�	new_token�currentNodeZcurrentNodeNamespaceZcurrentNodeNamer2r]Z	reprocessrFr)r)r*rN�sp










zHTMLParser.mainLoopccs x|jD]}|j|�VqWdS)N)rL�normalizeToken)r@r�r)r)r*rz�szHTMLParser.normalizedTokenscOs |j|ddf|�|�|jj�S)a�Parse a HTML document into a well-formed tree

        stream - a filelike object or string containing the HTML to be parsed

        The optional encoding parameter must be a string that indicates
        the encoding.  If specified, that encoding will be used,
        regardless of any BOM or later declaration (such as in a meta
        element)

        scripting - treat noscript elements as if javascript was turned on
        FN)rQr<ZgetDocument)r@rO�argsr&r)r)r*r#�szHTMLParser.parsecOs|j|df|�|�|jj�S)a2Parse a HTML fragment into a well-formed tree fragment

        container - name of the element we're setting the innerHTML property
        if set to None, default to 'div'

        stream - a filelike object or string containing the HTML to be parsed

        The optional encoding parameter must be a string that indicates
        the encoding.  If specified, that encoding will be used,
        regardless of any BOM or later declaration (such as in a meta
        element)

        scripting - treat noscript elements as if javascript was turned on
        T)rQr<ZgetFragment)r@rOr�r&r)r)r*r-�szHTMLParser.parseFragment�XXX-undefined-errorcCs@|dkri}|jj|jjj�||f�|jr<tt||��dS)N)rCr�rLrOZpositionrBrrr)r@�	errorcodertr)r)r*r|s
zHTMLParser.parseErrorcCsT|dtdkrP|d}t|�|d<t|�t|d�krP|dj|ddd��|S)z3 HTML5 specific normalizations to the token stream r2rorsNr	ry)rrr~�update)r@r��rawr)r)r*r�szHTMLParser.normalizeTokencCst|t�dS)N)�adjust_attributesr)r@r�r)r)r*rsz!HTMLParser.adjustMathMLAttributescCst|t�dS)N)r�r)r@r�r)r)r*rszHTMLParser.adjustSVGAttributescCst|t�dS)N)r��adjustForeignAttributesMap)r@r�r)r)r*rsz"HTMLParser.adjustForeignAttributescCs|jj�dS)N)rIr])r@r�r)r)r*�reparseTokenNormalszHTMLParser.reparseTokenNormalcCs�d}ddddddddddd	d	d
dd�}x�|jjddd�D]�}|j}d}||jjdkrl|jsbt�d}|j}|dkr~|js~t�|r�|j|jjkr�q:||kr�|j||}Pq:|r:|jd	}Pq:W||_dS)NF�inSelect�inCell�inRow�inTableBody�	inCaption�
inColumnGroup�inTable�inBody�
inFrameset�
beforeHead)�select�td�th�tr�tbody�thead�tfoot�caption�colgroup�table�head�body�frameset�htmlr	rTr�r�r�r�ry)r�r�r�r�)	r<r{r>rPr�rhrrFr])r@ZlastZnewModes�nodeZnodeNameZ	new_phaser)r)r*r_!sB


zHTMLParser.resetInsertionModecCsR|dkst�|jj|�|dkr.|jj|j_n|jj|j_|j|_|j	d|_dS)zYGeneric RCDATA/RAWTEXT Parsing algorithm
        contentType - RCDATA or RAWTEXT
        �RAWTEXT�RCDATA�textN)r�r�)
r�r<�
insertElementrLr[rZrYr]�
originalPhaserF)r@r�ZcontentTyper)r)r*�parseRCDataRawtextMszHTMLParser.parseRCDataRawtext)NFTF)Fr+F)r�N)r7r8r9�__doc__rHrQrM�propertyrcrlrmrNrzr#r-r|r�rrrr�r_r�r)r)r)r*r"8s&

"
C
,r"cs"dd�}dd�}Gdd�dt|||����Gdd�d��}Gd	d
�d
��}G�fdd�d��}G�fd
d�d��}G�fdd�d��}G�fdd�d��}G�fdd�d��}	G�fdd�d��}
G�fdd�d��}G�fdd�d��}G�fdd�d��}
G�fdd�d��}G�fdd �d ��}G�fd!d"�d"��}G�fd#d$�d$��}G�fd%d&�d&��}G�fd'd(�d(��}G�fd)d*�d*��}G�fd+d,�d,��}G�fd-d.�d.��}G�fd/d0�d0��}G�fd1d2�d2��}G�fd3d4�d4��}|||||||	|
|||
||||||||||||d5�S)6Ncs(tdd�tj�D�����fdd�}|S)z4Logger that records which phase processes each tokencss|]\}}||fVqdS)Nr))r=�key�valuer)r)r*�	<genexpr>csz)getPhases.<locals>.log.<locals>.<genexpr>cs��jjd�r�t|�dkr�|d}yd�|di}Wn�YnX|dtkr\|d|d<|jjj|jjjj|jj	j
j|j
j�j|f��|f|�|�S�|f|�|�SdS)NZprocessrr2r>)r7�
startswithr~rrIrVr�rLrZr]�	__class__)r@r�r&r��info)r6�
type_namesr)r*�wrappedfs
z'getPhases.<locals>.log.<locals>.wrapped)rDrr.)r6r�r))r6r�r*rVaszgetPhases.<locals>.logcSs|rt|�StSdS)N)r;r2)Z
use_metaclassZmetaclass_funcr)r)r*�getMetaclasszszgetPhases.<locals>.getMetaclassc@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)zgetPhases.<locals>.PhasezNBase class for helper object that implements each phase of processing
        cSs||_||_dS)N)rIr<)r@rIr<r)r)r*rH�sz!getPhases.<locals>.Phase.__init__cSst�dS)N)�NotImplementedError)r@r)r)r*r��sz#getPhases.<locals>.Phase.processEOFcSs|jj||jjd�dS)Nr	ry)r<�
insertCommentr{)r@r�r)r)r*r��sz'getPhases.<locals>.Phase.processCommentcSs|jjd�dS)Nzunexpected-doctype)rIr|)r@r�r)r)r*r��sz'getPhases.<locals>.Phase.processDoctypecSs|jj|d�dS)Nrs)r<�
insertText)r@r�r)r)r*r��sz*getPhases.<locals>.Phase.processCharacterscSs|jj|d�dS)Nrs)r<r�)r@r�r)r)r*r��sz/getPhases.<locals>.Phase.processSpaceCharacterscSs|j|d|�S)Nr>)�startTagHandler)r@r�r)r)r*r��sz(getPhases.<locals>.Phase.processStartTagcSsl|jjr"|ddkr"|jjd�x<|dj�D],\}}||jjdjkr0||jjdj|<q0Wd|j_dS)Nr>r�z
non-html-rootrsrF)rIrUr|r.r<r{ri)r@r��attrr�r)r)r*�startTagHtml�sz%getPhases.<locals>.Phase.startTagHtmlcSs|j|d|�S)Nr>)�
endTagHandler)r@r�r)r)r*r��sz&getPhases.<locals>.Phase.processEndTagN)
r7r8r9r�rHr�r�r�r�r�r�r�r�r)r)r)r*�Phase�s
r�c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)zgetPhases.<locals>.InitialPhasecSsdS)Nr))r@r�r)r)r*r��sz6getPhases.<locals>.InitialPhase.processSpaceCharacterscSs|jj||jj�dS)N)r<r��document)r@r�r)r)r*r��sz.getPhases.<locals>.InitialPhase.processCommentc8Ss|d}|d}|d}|d}|dks@|dk	s@|dk	rL|dkrL|jjd�|dkrXd}|jj|�|dkrv|jt�}|�s�|ddk�s�|jdJ��s�|dKk�s�|jdL��r�|dk�s�|�r�|j�dDk�r�dE|j_n*|jdM��s�|jdN��r|dk	�rdH|j_|jj	dI|j_
dS)ONr>�publicId�systemId�correctr�zabout:legacy-compatzunknown-doctype��*+//silmaril//dtd html pro v0r11 19970101//�4-//advasoft ltd//dtd html 3.0 aswedit + extensions//�*-//as//dtd html 3.0 aswedit + extensions//�-//ietf//dtd html 2.0 level 1//�-//ietf//dtd html 2.0 level 2//�&-//ietf//dtd html 2.0 strict level 1//�&-//ietf//dtd html 2.0 strict level 2//�-//ietf//dtd html 2.0 strict//�-//ietf//dtd html 2.0//�-//ietf//dtd html 2.1e//�-//ietf//dtd html 3.0//�-//ietf//dtd html 3.2 final//�-//ietf//dtd html 3.2//�-//ietf//dtd html 3//�-//ietf//dtd html level 0//�-//ietf//dtd html level 1//�-//ietf//dtd html level 2//�-//ietf//dtd html level 3//�"-//ietf//dtd html strict level 0//�"-//ietf//dtd html strict level 1//�"-//ietf//dtd html strict level 2//�"-//ietf//dtd html strict level 3//�-//ietf//dtd html strict//�-//ietf//dtd html//�(-//metrius//dtd metrius presentational//�5-//microsoft//dtd internet explorer 2.0 html strict//�.-//microsoft//dtd internet explorer 2.0 html//�0-//microsoft//dtd internet explorer 2.0 tables//�5-//microsoft//dtd internet explorer 3.0 html strict//�.-//microsoft//dtd internet explorer 3.0 html//�0-//microsoft//dtd internet explorer 3.0 tables//�#-//netscape comm. corp.//dtd html//�*-//netscape comm. corp.//dtd strict html//�*-//o'reilly and associates//dtd html 2.0//�3-//o'reilly and associates//dtd html extended 1.0//�;-//o'reilly and associates//dtd html extended relaxed 1.0//�N-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//�E-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//�$-//spyglass//dtd html 2.0 extended//�+-//sq//dtd html 2.0 hotmetal + extensions//�--//sun microsystems corp.//dtd hotjava html//�4-//sun microsystems corp.//dtd hotjava strict html//�-//w3c//dtd html 3 1995-03-24//�-//w3c//dtd html 3.2 draft//�-//w3c//dtd html 3.2 final//�-//w3c//dtd html 3.2//�-//w3c//dtd html 3.2s draft//�-//w3c//dtd html 4.0 frameset//�#-//w3c//dtd html 4.0 transitional//�(-//w3c//dtd html experimental 19960712//�&-//w3c//dtd html experimental 970421//�-//w3c//dtd w3 html//�-//w3o//dtd w3 html 3.0//�#-//webtechs//dtd mozilla html 2.0//�-//webtechs//dtd mozilla html//�$-//w3o//dtd w3 html strict 3.0//en//�"-/w3c/dtd html 4.0 transitional/en� -//w3c//dtd html 4.01 frameset//�$-//w3c//dtd html 4.01 transitional//z:http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd�quirks� -//w3c//dtd xhtml 1.0 frameset//�$-//w3c//dtd xhtml 1.0 transitional//zlimited quirksrS)7r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr)rrr�)rr)r	r
)rr)rIr|r<Z
insertDoctyperjrr�rXrWrFr])r@r�r>r�r�r�r)r)r*r��s�



z.getPhases.<locals>.InitialPhase.processDoctypecSsd|j_|jjd|j_dS)NrrS)rIrWrFr])r@r)r)r*�anythingElsesz,getPhases.<locals>.InitialPhase.anythingElsecSs|jjd�|j�|S)Nzexpected-doctype-but-got-chars)rIr|r)r@r�r)r)r*r�sz1getPhases.<locals>.InitialPhase.processCharacterscSs"|jjdd|di�|j�|S)Nz"expected-doctype-but-got-start-tagr>)rIr|r)r@r�r)r)r*r�sz/getPhases.<locals>.InitialPhase.processStartTagcSs"|jjdd|di�|j�|S)Nz expected-doctype-but-got-end-tagr>)rIr|r)r@r�r)r)r*r�sz-getPhases.<locals>.InitialPhase.processEndTagcSs|jjd�|j�dS)Nzexpected-doctype-but-got-eofT)rIr|r)r@r)r)r*r�%sz*getPhases.<locals>.InitialPhase.processEOFN)r7r8r9r�r�r�rr�r�r�r�r)r)r)r*�InitialPhase�s_rc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)z"getPhases.<locals>.BeforeHtmlPhasecSs&|jjtdd��|jjd|j_dS)Nr�ror�)r<Z
insertRoot�impliedTagTokenrIrFr])r@r)r)r*r^,sz4getPhases.<locals>.BeforeHtmlPhase.insertHtmlElementcSs|j�dS)NT)r^)r@r)r)r*r�1sz-getPhases.<locals>.BeforeHtmlPhase.processEOFcSs|jj||jj�dS)N)r<r�r�)r@r�r)r)r*r�5sz1getPhases.<locals>.BeforeHtmlPhase.processCommentcSsdS)Nr))r@r�r)r)r*r�8sz9getPhases.<locals>.BeforeHtmlPhase.processSpaceCharacterscSs|j�|S)N)r^)r@r�r)r)r*r�;sz4getPhases.<locals>.BeforeHtmlPhase.processCharacterscSs |ddkrd|j_|j�|S)Nr>r�T)rIrUr^)r@r�r)r)r*r�?sz2getPhases.<locals>.BeforeHtmlPhase.processStartTagcSs4|ddkr$|jjdd|di�n|j�|SdS)Nr>r�r�r��brzunexpected-end-tag-before-html)r�r�r�r)rIr|r^)r@r�r)r)r*r�Es
z0getPhases.<locals>.BeforeHtmlPhase.processEndTagN)
r7r8r9r^r�r�r�r�r�r�r)r)r)r*�BeforeHtmlPhase*srcsXeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)z"getPhases.<locals>.BeforeHeadPhasecsV�j|||�tjd|jfd|jfg�|_|j|j_tjd|jfg�|_	|j
|j	_dS)Nr�r�r�r)r�r�r�r)rHr�MethodDispatcherr��startTagHeadr��
startTagOther�default�endTagImplyHeadr��endTagOther)r@rIr<)r�r)r*rHNs
z+getPhases.<locals>.BeforeHeadPhase.__init__cSs|jtdd��dS)Nr�roT)rr
)r@r)r)r*r�\sz-getPhases.<locals>.BeforeHeadPhase.processEOFcSsdS)Nr))r@r�r)r)r*r�`sz9getPhases.<locals>.BeforeHeadPhase.processSpaceCharacterscSs|jtdd��|S)Nr�ro)rr
)r@r�r)r)r*r�csz4getPhases.<locals>.BeforeHeadPhase.processCharacterscSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r�gsz/getPhases.<locals>.BeforeHeadPhase.startTagHtmlcSs0|jj|�|jjd|j_|jjd|j_dS)Nr	�inHeadry)r<r�r{�headPointerrIrFr])r@r�r)r)r*rjsz/getPhases.<locals>.BeforeHeadPhase.startTagHeadcSs|jtdd��|S)Nr�ro)rr
)r@r�r)r)r*rosz0getPhases.<locals>.BeforeHeadPhase.startTagOthercSs|jtdd��|S)Nr�ro)rr
)r@r�r)r)r*rssz2getPhases.<locals>.BeforeHeadPhase.endTagImplyHeadcSs|jjdd|di�dS)Nzend-tag-after-implied-rootr>)rIr|)r@r�r)r)r*rwsz.getPhases.<locals>.BeforeHeadPhase.endTagOtherN)r7r8r9rHr�r�r�r�rrrrr))r�r)r*�BeforeHeadPhaseMsrcs�eZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!S)"zgetPhases.<locals>.InHeadPhasecs��j|||�tjd|jfd|jfd|jfd|jfd|jfd|jfd|j	fd
|j
fg�|_|j|j_
tjd
|jfd|jfg�|_|j|j_
dS)Nr��title�noframes�style�noscript�script�base�basefont�bgsound�command�linkr4r�rr�)rr)rrr r!r")rr�r�)rHrrr��
startTagTitle�startTagNoFramesStyle�startTagNoscript�startTagScript�startTagBaseLinkCommand�startTagMetarr�rr�
endTagHead�endTagHtmlBodyBrr�r)r@rIr<)r�r)r*rH|s 
z'getPhases.<locals>.InHeadPhase.__init__cSs|j�dS)NT)r)r@r)r)r*r��sz)getPhases.<locals>.InHeadPhase.processEOFcSs|j�|S)N)r)r@r�r)r)r*r��sz0getPhases.<locals>.InHeadPhase.processCharacterscSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r��sz+getPhases.<locals>.InHeadPhase.startTagHtmlcSs|jjd�dS)Nz!two-heads-are-not-better-than-one)rIr|)r@r�r)r)r*r�sz+getPhases.<locals>.InHeadPhase.startTagHeadcSs$|jj|�|jjj�d|d<dS)NTrx)r<r�r{�pop)r@r�r)r)r*r'�sz6getPhases.<locals>.InHeadPhase.startTagBaseLinkCommandcSs�|jj|�|jjj�d|d<|d}|jjjjddkr�d|krZ|jjjj|d�nVd|kr�d|kr�|dj	�d	kr�t
j|djd
��}t
j
|�}|j�}|jjjj|�dS)NTrxrsr	Z	tentative�charsetZcontentz
http-equivzcontent-typezutf-8)r<r�r{r+rIrLrOrbZchangeEncodingrXr
Z
EncodingBytes�encodeZContentAttrParserr#)r@r�rirsrI�codecr)r)r*r(�s
z+getPhases.<locals>.InHeadPhase.startTagMetacSs|jj|d�dS)Nr�)rIr�)r@r�r)r)r*r#�sz,getPhases.<locals>.InHeadPhase.startTagTitlecSs|jj|d�dS)Nr�)rIr�)r@r�r)r)r*r$�sz4getPhases.<locals>.InHeadPhase.startTagNoFramesStylecSs8|jjr|jj|d�n|jj|�|jjd|j_dS)Nr��inHeadNoscript)rIrKr�r<r�rFr])r@r�r)r)r*r%�sz/getPhases.<locals>.InHeadPhase.startTagNoscriptcSs<|jj|�|jjj|jj_|jj|j_|jjd|j_dS)Nr�)	r<r�rIrLZscriptDataStaterZr]r�rF)r@r�r)r)r*r&�sz-getPhases.<locals>.InHeadPhase.startTagScriptcSs|j�|S)N)r)r@r�r)r)r*r�sz,getPhases.<locals>.InHeadPhase.startTagOthercSs:|jjjj�}|jdks&td|j��|jjd|j_dS)Nr�zExpected head got %s�	afterHead)rIr<r{r+r>r�rFr])r@r�r�r)r)r*r)�sz)getPhases.<locals>.InHeadPhase.endTagHeadcSs|j�|S)N)r)r@r�r)r)r*r*�sz/getPhases.<locals>.InHeadPhase.endTagHtmlBodyBrcSs|jjdd|di�dS)Nzunexpected-end-tagr>)rIr|)r@r�r)r)r*r�sz*getPhases.<locals>.InHeadPhase.endTagOthercSs|jtd��dS)Nr�)r)r
)r@r)r)r*r�sz+getPhases.<locals>.InHeadPhase.anythingElseN)r7r8r9rHr�r�r�rr'r(r#r$r%r&rr)r*rrr))r�r)r*�InHeadPhase{s r1csxeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)z&getPhases.<locals>.InHeadNoscriptPhasecsf�j|||�tjd|jfd|jfd|jfg�|_|j|j_tjd	|j	fd
|j
fg�|_|j|j_dS)
Nr�rr r"r4rrr�rr)rr r"r4rr)r�r)
rHrrr�r'�startTagHeadNoscriptr�rr�endTagNoscript�endTagBrr�r)r@rIr<)r�r)r*rH�s
z/getPhases.<locals>.InHeadNoscriptPhase.__init__cSs|jjd�|j�dS)Nzeof-in-head-noscriptT)rIr|r)r@r)r)r*r��sz1getPhases.<locals>.InHeadNoscriptPhase.processEOFcSs|jjdj|�S)Nr)rIrFr�)r@r�r)r)r*r��sz5getPhases.<locals>.InHeadNoscriptPhase.processCommentcSs|jjd�|j�|S)Nzchar-in-head-noscript)rIr|r)r@r�r)r)r*r��sz8getPhases.<locals>.InHeadNoscriptPhase.processCharacterscSs|jjdj|�S)Nr)rIrFr�)r@r�r)r)r*r�sz=getPhases.<locals>.InHeadNoscriptPhase.processSpaceCharacterscSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r�sz3getPhases.<locals>.InHeadNoscriptPhase.startTagHtmlcSs|jjdj|�S)Nr)rIrFr�)r@r�r)r)r*r'sz>getPhases.<locals>.InHeadNoscriptPhase.startTagBaseLinkCommandcSs|jjdd|di�dS)Nzunexpected-start-tagr>)rIr|)r@r�r)r)r*r2	sz;getPhases.<locals>.InHeadNoscriptPhase.startTagHeadNoscriptcSs"|jjdd|di�|j�|S)Nzunexpected-inhead-noscript-tagr>)rIr|r)r@r�r)r)r*rsz4getPhases.<locals>.InHeadNoscriptPhase.startTagOthercSs:|jjjj�}|jdks&td|j��|jjd|j_dS)NrzExpected noscript got %sr)rIr<r{r+r>r�rFr])r@r�r�r)r)r*r3sz5getPhases.<locals>.InHeadNoscriptPhase.endTagNoscriptcSs"|jjdd|di�|j�|S)Nzunexpected-inhead-noscript-tagr>)rIr|r)r@r�r)r)r*r4sz/getPhases.<locals>.InHeadNoscriptPhase.endTagBrcSs|jjdd|di�dS)Nzunexpected-end-tagr>)rIr|)r@r�r)r)r*rsz2getPhases.<locals>.InHeadNoscriptPhase.endTagOthercSs|jtd��dS)Nr)r3r
)r@r)r)r*rsz3getPhases.<locals>.InHeadNoscriptPhase.anythingElseN)r7r8r9rHr�r�r�r�r�r'r2rr3r4rrr))r�r)r*�InHeadNoscriptPhase�sr5cspeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)z!getPhases.<locals>.AfterHeadPhasec
sn�j|||�tjd|jfd|jfd|jfd|jfd
|jfg�|_|j	|j_
tjd|jfg�|_|j
|j_
dS)Nr�r�r�rrr r"r4rrrrr�r)	rrr r"r4rrrr)r�r�r)rHrrr��startTagBody�startTagFrameset�startTagFromHeadrr�rrr*r�r)r@rIr<)r�r)r*rH#s
z*getPhases.<locals>.AfterHeadPhase.__init__cSs|j�dS)NT)r)r@r)r)r*r�4sz,getPhases.<locals>.AfterHeadPhase.processEOFcSs|j�|S)N)r)r@r�r)r)r*r�8sz3getPhases.<locals>.AfterHeadPhase.processCharacterscSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r�<sz.getPhases.<locals>.AfterHeadPhase.startTagHtmlcSs(d|j_|jj|�|jjd|j_dS)NFr�)rIr`r<r�rFr])r@r�r)r)r*r6?sz.getPhases.<locals>.AfterHeadPhase.startTagBodycSs |jj|�|jjd|j_dS)Nr�)r<r�rIrFr])r@r�r)r)r*r7Dsz2getPhases.<locals>.AfterHeadPhase.startTagFramesetcSst|jjdd|di�|jjj|jj�|jjdj|�x4|jjddd�D]}|jdkrN|jjj	|�PqNWdS)Nz#unexpected-start-tag-out-of-my-headr>rr	r�ry)
rIr|r<r{r�rrFr�r>�remove)r@r�r�r)r)r*r8Hs
z2getPhases.<locals>.AfterHeadPhase.startTagFromHeadcSs|jjdd|di�dS)Nzunexpected-start-tagr>)rIr|)r@r�r)r)r*rRsz.getPhases.<locals>.AfterHeadPhase.startTagHeadcSs|j�|S)N)r)r@r�r)r)r*rUsz/getPhases.<locals>.AfterHeadPhase.startTagOthercSs|j�|S)N)r)r@r�r)r)r*r*Ysz2getPhases.<locals>.AfterHeadPhase.endTagHtmlBodyBrcSs|jjdd|di�dS)Nzunexpected-end-tagr>)rIr|)r@r�r)r)r*r]sz-getPhases.<locals>.AfterHeadPhase.endTagOthercSs.|jjtdd��|jjd|j_d|j_dS)Nr�ror�T)r<r�r
rIrFr]r`)r@r)r)r*r`sz.getPhases.<locals>.AfterHeadPhase.anythingElseN)r7r8r9rHr�r�r�r6r7r8rrr*rrr))r�r)r*�AfterHeadPhase"s
r:cs�eZdZ�fdd�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#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+dSdT�Z,dUdV�Z-dWdX�Z.dYdZ�Z/d[d\�Z0d]d^�Z1d_d`�Z2dadb�Z3dcdd�Z4dedf�Z5dgS)hzgetPhases.<locals>.InBodyPhasec,s��j|||�|j|_tjd|jfdd|jfd|jfd|jfde|j	ft
|jfdf|jfd&|j
fdg|jfd*|jfd+|jfdh|jfd8|jfd9|jfdi|jfd=|jfd>|jfdj|jfdk|jfdH|jfdI|jfdJ|jfdK|jfdL|jfdM|jfdN|jfdl|j fdQ|j!fdm|j"fdn|j#fdV|j$fdW|j%fdo|j&fg!�|_'|j(|j'_)tjd|j*fd|j+fdp|j,fd&|j-fd |j.fdq|j/ft
|j0fdr|j1fds|j2fd@|j3fg
�|_4|j5|j4_)dS)tNr�rrr r!r"r4rrrr�r��address�article�aside�
blockquote�center�details�dirr+�dl�fieldset�
figcaption�figure�footer�header�hgroup�main�menu�nav�olr(�section�summary�ul�pre�listing�form�li�dd�dtrR�a�b�big�code�em�font�i�s�small�strike�strong�tt�u�nobr�button�applet�marquee�objectZxmpr��arear�embed�img�keygen�wbr�param�source�track�input�hr�image�isindex�textareaZiframer�noembedrr��rp�rt�option�optgroupZmathrur��colr��framer�r�r�r�r�r�r��dialog)	rrr r!r"r4rrr)r;r<r=r>r?r@rAr+rBrCrDrErFrGrHrIrJrKrLr(rMrNrO)rPrQ)rSrTrU)rWrXrYrZr[r\r]r^r_r`rarb)rerfrg)rhrrirjrkrl)rmrnro)rur)rvrw)rxry)r�rzr�r{r�r�r�r�r�r�r�)r;r<r=r>rdr?r@r|rAr+rBrCrDrErFrGrHrQrIrJrKrLrPrMrNrO)rTrUrS)rVrWrXrYrZr[r\rcr]r^r_r`rarb)rerfrg)6rH�processSpaceCharactersNonPrer�rrr��startTagProcessInHeadr6r7�startTagClosePr�startTagHeading�startTagPreListing�startTagForm�startTagListItem�startTagPlaintext�	startTagA�startTagFormatting�startTagNobr�startTagButton�startTagAppletMarqueeObject�startTagXmp�
startTagTable�startTagVoidFormatting�startTagParamSource�
startTagInput�
startTagHr�
startTagImage�startTagIsIndex�startTagTextarea�startTagIFramer%�startTagRawtext�startTagSelect�startTagRpRt�startTagOpt�startTagMath�startTagSvg�startTagMisplacedr�rr�
endTagBody�
endTagHtml�endTagBlock�
endTagForm�endTagP�endTagListItem�
endTagHeading�endTagFormatting�endTagAppletMarqueeObjectr4r�r)r@rIr<)r�r)r*rHhs~
z'getPhases.<locals>.InBodyPhase.__init__cSs$|j|jko"|j|jko"|j|jkS)N)r>rhri)r@Znode1Znode2r)r)r*�isMatchingFormattingElement�sz:getPhases.<locals>.InBodyPhase.isMatchingFormattingElementcSs�|jj|�|jjd}g}x<|jjddd�D]&}|tkr@Pq0|j||�r0|j|�q0Wt|�dksjt�t|�dkr�|jjj	|d�|jjj|�dS)Nr	�ryryry)
r<r�r{�activeFormattingElementsr
r�r�r~r�r9)r@r�rkZmatchingElementsr�r)r)r*�addFormattingElement�sz3getPhases.<locals>.InBodyPhase.addFormattingElementc
Ss@td�}x2|jjddd�D]}|j|kr|jjd�PqWdS)NrTrUrSr(r�r�r�r�r�r�r�r�r	z expected-closing-tag-but-got-eof)rTrUrSr(r�r�r�r�r�r�r�r�ry)r�r<r{r>rIr|)r@Zallowed_elementsr�r)r)r*r��s
z)getPhases.<locals>.InBodyPhase.processEOFcSsh|d}|j|_|jd�rJ|jjdjdkrJ|jjd	j�rJ|dd�}|rd|jj�|jj|�dS)
Nrs�
r	rPrQrtry)rPrQrtry)	r}r�r�r<r{r>Z
hasContent�#reconstructActiveFormattingElementsr�)r@r�rsr)r)r*�!processSpaceCharactersDropNewline�s

z@getPhases.<locals>.InBodyPhase.processSpaceCharactersDropNewlinecSsT|ddkrdS|jj�|jj|d�|jjrPtdd�|dD��rPd|j_dS)Nrs�cSsg|]}|tk�qSr))r)r=�charr)r)r*rA�szDgetPhases.<locals>.InBodyPhase.processCharacters.<locals>.<listcomp>F)r<r�r�rIr`�any)r@r�r)r)r*r��s
z0getPhases.<locals>.InBodyPhase.processCharacterscSs|jj�|jj|d�dS)Nrs)r<r�r�)r@r�r)r)r*r}�s
z;getPhases.<locals>.InBodyPhase.processSpaceCharactersNonPrecSs|jjdj|�S)Nr)rIrFr�)r@r�r)r)r*r~�sz4getPhases.<locals>.InBodyPhase.startTagProcessInHeadcSs�|jjdddi�t|jj�dks4|jjdjdkrB|jjs�t�nFd|j_x<|dj	�D],\}}||jjdj
krX||jjdj
|<qXWdS)Nzunexpected-start-tagr>r�r	Frs)rIr|r~r<r{r>rPr�r`r.ri)r@r�r�r�r)r)r*r6�sz+getPhases.<locals>.InBodyPhase.startTagBodycSs�|jjdddi�t|jj�dks4|jjdjdkrB|jjs�t�nt|jjsLnj|jjdj	rv|jjdj	j
|jjd�x"|jjdjdkr�|jjj�qxW|jj|�|jj
d|j_dS)	Nzunexpected-start-tagr>r�r	r�r�r�ry)rIr|r~r<r{r>rPr�r`�parent�removeChildr+r�rFr])r@r�r)r)r*r7�s"z/getPhases.<locals>.InBodyPhase.startTagFramesetcSs.|jjddd�r|jtd��|jj|�dS)Nr(rd)�variant)r<�elementInScoper�r
r�)r@r�r)r)r*r	sz-getPhases.<locals>.InBodyPhase.startTagClosePcSs>|jjddd�r|jtd��|jj|�d|j_|j|_dS)Nr(rd)r�F)	r<r�r�r
r�rIr`r�r�)r@r�r)r)r*r�s
z1getPhases.<locals>.InBodyPhase.startTagPreListingcSsZ|jjr|jjdddi�n:|jjddd�r:|jtd��|jj|�|jjd|j_dS)	Nzunexpected-start-tagr>rRr(rd)r�r	ry)	r<�formPointerrIr|r�r�r
r�r{)r@r�r)r)r*r�sz+getPhases.<locals>.InBodyPhase.startTagFormcSs�d|j_dgddgddgd�}||d}xLt|jj�D]<}|j|kr^|jjjt|jd��P|j	t
kr8|jd
kr8Pq8W|jjd
dd�r�|jjjtd
d��|jj|�dS)NFrSrUrT)rSrUrTr>rpr;r+r(rd)r�)r;r+r()
rIr`�reversedr<r{r>r]r�r
�	nameTuplerr�r�)r@r�ZstopNamesMapZ	stopNamesr�r)r)r*r�s"


z/getPhases.<locals>.InBodyPhase.startTagListItemcSs>|jjddd�r|jtd��|jj|�|jjj|jj_dS)Nr(rd)r�)	r<r�r�r
r�rIrLr\rZ)r@r�r)r)r*r�4sz0getPhases.<locals>.InBodyPhase.startTagPlaintextcSsb|jjddd�r|jtd��|jjdjtkrR|jjdd|di�|jjj	�|jj
|�dS)Nr(rd)r�r	zunexpected-start-tagr>ry)r<r�r�r
r{r>rrIr|r+r�)r@r�r)r)r*r�:sz.getPhases.<locals>.InBodyPhase.startTagHeadingcSs~|jjd�}|rf|jjdddd��|jtd��||jjkrL|jjj|�||jjkrf|jjj|�|jj	�|j
|�dS)NrVz$unexpected-start-tag-implies-end-tag)�	startName�endName)r<�!elementInActiveFormattingElementsrIr|r�r
r{r9r�r�r�)r@r�ZafeAElementr)r)r*r�Bs
z(getPhases.<locals>.InBodyPhase.startTagAcSs|jj�|j|�dS)N)r<r�r�)r@r�r)r)r*r�Os
z1getPhases.<locals>.InBodyPhase.startTagFormattingcSsP|jj�|jjd�rB|jjdddd��|jtd��|jj�|j|�dS)Nrcz$unexpected-start-tag-implies-end-tag)r�r�)r<r�r�rIr|r�r
r�)r@r�r)r)r*r�Ss

z+getPhases.<locals>.InBodyPhase.startTagNobrcSsT|jjd�r2|jjdddd��|jtd��|S|jj�|jj|�d|j_dS)Nrdz$unexpected-start-tag-implies-end-tag)r�r�F)	r<r�rIr|r�r
r�r�r`)r@r�r)r)r*r�]s
z-getPhases.<locals>.InBodyPhase.startTagButtoncSs0|jj�|jj|�|jjjt�d|j_dS)NF)r<r�r�r�r�r
rIr`)r@r�r)r)r*r�hs
z:getPhases.<locals>.InBodyPhase.startTagAppletMarqueeObjectcSsB|jjddd�r|jtd��|jj�d|j_|jj|d�dS)Nr(rd)r�Fr�)r<r�r�r
r�rIr`r�)r@r�r)r)r*r�ns

z*getPhases.<locals>.InBodyPhase.startTagXmpcSsR|jjdkr*|jjddd�r*|jtd��|jj|�d|j_|jjd|j_	dS)Nrr(rd)r�Fr�)
rIrWr<r�r�r
r�r`rFr])r@r�r)r)r*r�usz,getPhases.<locals>.InBodyPhase.startTagTablecSs6|jj�|jj|�|jjj�d|d<d|j_dS)NTrxF)r<r�r�r{r+rIr`)r@r�r)r)r*r�}s

z5getPhases.<locals>.InBodyPhase.startTagVoidFormattingcSs@|jj}|j|�d|dkr<|ddjt�dkr<||j_dS)Nr2rs�hidden)rIr`r�rjr)r@r�r`r)r)r*r��s

z,getPhases.<locals>.InBodyPhase.startTagInputcSs$|jj|�|jjj�d|d<dS)NTrx)r<r�r{r+)r@r�r)r)r*r��sz2getPhases.<locals>.InBodyPhase.startTagParamSourcecSsJ|jjddd�r|jtd��|jj|�|jjj�d|d<d|j_dS)Nr(rd)r�TrxF)	r<r�r�r
r�r{r+rIr`)r@r�r)r)r*r��sz)getPhases.<locals>.InBodyPhase.startTagHrcSs6|jjdddd��|jtdd|d|dd��dS)	Nzunexpected-start-tag-treated-asrrrj)�originalName�newNamerorsrw)rirw)rIr|r�r
)r@r�r)r)r*r��s

z,getPhases.<locals>.InBodyPhase.startTagImagecSs|jjdddi�|jjrdSi}d|dkr>|dd|d<|jtdd|d��|jtd	d��|jtd
d��d|dkr�|dd}nd}|jtd
|d��|dj�}d|kr�|d=d|kr�|d=d|d<|jtdd||dd��|j	td
��|jtd	d��|j	td��dS)Nzdeprecated-tagr>rs�actionrsrRro)rirqZlabel�promptz3This is a searchable index. Enter search keywords: rn)r2rsrprw)rirw)
rIr|r<r�r�r
r�r�copyr�)r@r�Z
form_attrsr�rir)r)r*r��s6


z.getPhases.<locals>.InBodyPhase.startTagIsIndexcSs0|jj|�|jjj|jj_|j|_d|j_dS)NF)	r<r�rIrLrYrZr�r�r`)r@r�r)r)r*r��sz/getPhases.<locals>.InBodyPhase.startTagTextareacSsd|j_|j|�dS)NF)rIr`r�)r@r�r)r)r*r��sz-getPhases.<locals>.InBodyPhase.startTagIFramecSs"|jjr|j|�n
|j|�dS)N)rIrKr�r)r@r�r)r)r*r%�sz/getPhases.<locals>.InBodyPhase.startTagNoscriptcSs|jj|d�dS)z8iframe, noembed noframes, noscript(if scripting enabled)r�N)rIr�)r@r�r)r)r*r��sz.getPhases.<locals>.InBodyPhase.startTagRawtextcSs@|jjdjdkr$|jjjtd��|jj�|jjj|�dS)Nr	rxry)	r<r{r>rIr]r�r
r�r�)r@r�r)r)r*r��s
z*getPhases.<locals>.InBodyPhase.startTagOptcSs�|jj�|jj|�d|j_|jj|jjd|jjd|jjd|jjd|jjd|jjdfkrx|jjd|j_n|jjd	|j_dS)
NFr�r�r�r�r�r��inSelectInTabler�)r<r�r�rIr`r]rF)r@r�r)r)r*r��s




z-getPhases.<locals>.InBodyPhase.startTagSelectcSsB|jjd�r2|jj�|jjdjdkr2|jj�|jj|�dS)N�rubyr	ry)r<r��generateImpliedEndTagsr{r>rIr|r�)r@r�r)r)r*r��s


z+getPhases.<locals>.InBodyPhase.startTagRpRtcSsZ|jj�|jj|�|jj|�td|d<|jj|�|drV|jjj�d|d<dS)NrdrhrwTrx)	r<r�rIrrrr�r{r+)r@r�r)r)r*r��s
z+getPhases.<locals>.InBodyPhase.startTagMathcSsZ|jj�|jj|�|jj|�td|d<|jj|�|drV|jjj�d|d<dS)NrurhrwTrx)	r<r�rIrrrr�r{r+)r@r�r)r)r*r��s
z*getPhases.<locals>.InBodyPhase.startTagSvgcSs|jjdd|di�dS)a5 Elements that should be children of other elements that have a
            different insertion mode; here they are ignored
            "caption", "col", "colgroup", "frame", "frameset", "head",
            "option", "optgroup", "tbody", "td", "tfoot", "th", "thead",
            "tr", "noscript"
            zunexpected-start-tag-ignoredr>N)rIr|)r@r�r)r)r*r�sz0getPhases.<locals>.InBodyPhase.startTagMisplacedcSs|jj�|jj|�dS)N)r<r�r�)r@r�r)r)r*rs
z,getPhases.<locals>.InBodyPhase.startTagOthercSs�|jjddd�sD|jtdd��|jjdddi�|jtdd��nX|jjd�|jjd	j	dkrt|jjdddi�|jjj
�}x|j	dkr�|jjj
�}q�WdS)
Nr(rd)r�rozunexpected-end-tagr>rpr	ry)r<r�rr
rIr|r�r�r{r>r+)r@r�r�r)r)r*r�sz&getPhases.<locals>.InBodyPhase.endTagPcSs�|jjd�s|jj�dS|jjdjdkrlx>|jjdd�D]*}|jtd�kr>|jjdd|jd��Pq>W|jjd|j_dS)Nr�r	�rTrUrSryrxr(rvrwr�r�r�r�r�r�r�z$expected-one-end-tag-but-got-another)�gotName�expectedName�	afterBodyry)rTrUrSryrxr(rvrwr�r�r�r�r�r�r�r�)	r<r�rIr|r{r>r�rFr])r@r�r�r)r)r*r�!s
z)getPhases.<locals>.InBodyPhase.endTagBodycSs"|jjd�r|jtd��|SdS)Nr�)r<r�r�r
)r@r�r)r)r*r�3sz)getPhases.<locals>.InBodyPhase.endTagHtmlcSs�|ddkr|j|_|jj|d�}|r2|jj�|jjdj|dkr^|jjdd|di�|r�|jjj	�}x|j|dkr�|jjj	�}qpWdS)Nr>rPr	zend-tag-too-earlyry)
r}r�r<r�r�r{r>rIr|r+)r@r�ZinScoper�r)r)r*r�9s
z*getPhases.<locals>.InBodyPhase.endTagBlockcSsx|jj}d|j_|dks&|jj|�r:|jjdddi�n:|jj�|jjd|krf|jjdddi�|jjj|�dS)Nzunexpected-end-tagr>rRr	zend-tag-too-early-ignoredry)r<r�r�rIr|r�r{r9)r@r�r�r)r)r*r�Gs

z)getPhases.<locals>.InBodyPhase.endTagFormcSs�|ddkrd}nd}|jj|d|d�sB|jjdd|di�nj|jj|dd�|jjd	j|dkr�|jjdd|di�|jjj�}x|j|dkr�|jjj�}q�WdS)
Nr>rS�list)r�zunexpected-end-tag)�excluder	zend-tag-too-earlyry)r<r�rIr|r�r{r>r+)r@r�r�r�r)r)r*r�Tsz-getPhases.<locals>.InBodyPhase.endTagListItemcSs�x$tD]}|jj|�r|jj�PqW|jjdj|dkrR|jjdd|di�xBtD]:}|jj|�rX|jjj�}x|jtkr�|jjj�}qvWPqXWdS)Nr	r>zend-tag-too-earlyry)	rr<r�r�r{r>rIr|r+)r@r��itemr)r)r*r�es


z,getPhases.<locals>.InBodyPhase.endTagHeadingcSs"d}�x|dk�r|d7}|jj|d�}|sL||jjkrZ|jj|j�rZ|j|�dS||jjkr�|jjdd|di�|jjj	|�dS|jj|j�s�|jjdd|di�dS||jjdkr�|jjdd|di�|jjj
|�}d}x,|jj|d�D]}|jtk�r|}P�qW|dk�rb|jjj
�}x||k�rN|jjj
�}�q4W|jjj	|�dS|jj|d}|jjj
|�}|}	}
d}|jjj
|
�}x�|d	k�rh|d7}|d8}|jj|}
|
|jjk�r�|jjj	|
��q�|
|k�r�P|	|k�r
|jjj
|
�d}|
j�}
|
|jj|jjj
|
�<|
|jj|jjj
|
�<|
}
|	j�rV|	jj|	�|
j|	�|
}	�q�W|	j�r~|	jj|	�|jtd�k�r�|jj�\}}|j|	|�n
|j|	�|j�}
|j|
�|j|
�|jjj	|�|jjj||
�|jjj	|�|jjj|jjj
|�d|
�qWdS)z)The much-feared adoption agency algorithmr�r	r>Nzadoption-agency-1.2zadoption-agency-4.4zadoption-agency-1.3r�r�r�r�r�r�ry)r�r�r�r�r�)r<r�r{r�r>rrIr|r�r9�indexr�rr+Z	cloneNoder�r�ZappendChildr�ZgetTableMisnestedNodePosition�insertBeforeZreparentChildren�insert)r@r�ZouterLoopCounterZformattingElementZafeIndexZ
furthestBlockrkZcommonAncestorZbookmarkZlastNoder�ZinnerLoopCounterr�Zcloner�r�r)r)r*r�ts�











z/getPhases.<locals>.InBodyPhase.endTagFormattingcSs�|jj|d�r|jj�|jjdj|dkrF|jjdd|di�|jj|d�r�|jjj�}x|j|dkr�|jjj�}qdW|jj�dS)Nr>r	zend-tag-too-earlyry)	r<r�r�r{r>rIr|r+�clearActiveFormattingElements)r@r�rkr)r)r*r�s
z8getPhases.<locals>.InBodyPhase.endTagAppletMarqueeObjectcSs@|jjdddd��|jj�|jjtdd��|jjj�dS)Nzunexpected-end-tag-treated-asrz
br element)r�r�ro)rIr|r<r�r�r
r{r+)r@r�r)r)r*r4#s

z'getPhases.<locals>.InBodyPhase.endTagBrcSs�x�|jjddd�D]�}|j|dkr~|jj|dd�|jjdj|dkrd|jjdd|di�x|jjj�|krxqfWPq|jtkr|jjdd|di�PqWdS)Nr	r>)r�zunexpected-end-tagryry)	r<r{r>r�rIr|r+r�r)r@r�r�r)r)r*r*s
z*getPhases.<locals>.InBodyPhase.endTagOtherN)6r7r8r9rHr�r�r�r�r�r}r~r6r7rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r%r�r�r�r�r�r�r�rr�r�r�r�r�r�r�r�r�r4rr))r�r)r*�InBodyPhaseeshG

	

	

$r�cs@eZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)zgetPhases.<locals>.TextPhasecsF�j|||�tjg�|_|j|j_tjd|jfg�|_|j|j_dS)Nr)	rHrrr�rr�endTagScriptr�r)r@rIr<)r�r)r*rH9s
z%getPhases.<locals>.TextPhase.__init__cSs|jj|d�dS)Nrs)r<r�)r@r�r)r)r*r�Asz.getPhases.<locals>.TextPhase.processCharacterscSs8|jjdd|jjdji�|jjj�|jj|j_dS)Nz&expected-named-closing-tag-but-got-eofr>r	Try)rIr|r<r{r>r+r�r])r@r)r)r*r�Ds
z'getPhases.<locals>.TextPhase.processEOFcSsdstd|d��dS)NFz4Tried to process start tag %s in RCDATA/RAWTEXT moder>)r�)r@r�r)r)r*rKsz*getPhases.<locals>.TextPhase.startTagOthercSs*|jjj�}|jdkst�|jj|j_dS)Nr)r<r{r+r>r�rIr�r])r@r�r�r)r)r*r�Nsz)getPhases.<locals>.TextPhase.endTagScriptcSs|jjj�|jj|j_dS)N)r<r{r+rIr�r])r@r�r)r)r*rUsz(getPhases.<locals>.TextPhase.endTagOtherN)	r7r8r9rHr�r�rr�rr))r�r)r*�	TextPhase8sr�cs�eZdZ�fdd�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'S)(zgetPhases.<locals>.InTablePhasec
s��j|||�tjd|jfd|jfd|jfd|jfd|jfd|jfd|j	fd|j
fd|jfd|jfg
�|_
|j|j
_tjd|jfd|jfg�|_|j|j_dS)Nr�r�r�rzr�r�r�r�r�r�r�rrrprRr�)r�r�r�)r�r�r�)rr)r�r�rzr�r�r�r�r�r�r�r�)rHrrr��startTagCaption�startTagColgroup�startTagCol�startTagRowGroup�startTagImplyTbodyr��startTagStyleScriptr�r�r�rr�endTagTable�endTagIgnorer�r)r@rIr<)r�r)r*rH[s$
z(getPhases.<locals>.InTablePhase.__init__cSs(x"|jjdjdkr"|jjj�qWdS)Nr	r�r�ry)r�r�)r<r{r>r+)r@r)r)r*�clearStackToTableContextssz8getPhases.<locals>.InTablePhase.clearStackToTableContextcSs0|jjdjdkr |jjd�n|jjs,t�dS)Nr	r�zeof-in-tablery)r<r{r>rIr|rPr�)r@r)r)r*r�|sz*getPhases.<locals>.InTablePhase.processEOFcSs4|jj}|jjd|j_||jj_|jjj|�dS)N�inTableText)rIr]rFr�r�)r@r�r�r)r)r*r��s
z6getPhases.<locals>.InTablePhase.processSpaceCharacterscSs4|jj}|jjd|j_||jj_|jjj|�dS)Nr�)rIr]rFr�r�)r@r�r�r)r)r*r��s
z1getPhases.<locals>.InTablePhase.processCharacterscSs&d|j_|jjdj|�d|j_dS)NTr�F)r<�insertFromTablerIrFr�)r@r�r)r)r*r��sz*getPhases.<locals>.InTablePhase.insertTextcSs6|j�|jjjt�|jj|�|jjd|j_dS)Nr�)	r�r<r�r�r
r�rIrFr])r@r�r)r)r*r��sz/getPhases.<locals>.InTablePhase.startTagCaptioncSs(|j�|jj|�|jjd|j_dS)Nr�)r�r<r�rIrFr])r@r�r)r)r*r��sz0getPhases.<locals>.InTablePhase.startTagColgroupcSs|jtdd��|S)Nr�ro)r�r
)r@r�r)r)r*r��sz+getPhases.<locals>.InTablePhase.startTagColcSs(|j�|jj|�|jjd|j_dS)Nr�)r�r<r�rIrFr])r@r�r)r)r*r��sz0getPhases.<locals>.InTablePhase.startTagRowGroupcSs|jtdd��|S)Nr�ro)r�r
)r@r�r)r)r*r��sz2getPhases.<locals>.InTablePhase.startTagImplyTbodycSs6|jjdddd��|jjjtd��|jjs2|SdS)Nz$unexpected-start-tag-implies-end-tagr�)r�r�)rIr|r]r�r
rP)r@r�r)r)r*r��s
z-getPhases.<locals>.InTablePhase.startTagTablecSs|jjdj|�S)Nr)rIrFr�)r@r�r)r)r*r��sz3getPhases.<locals>.InTablePhase.startTagStyleScriptcSsVd|dkrH|ddjt�dkrH|jjd�|jj|�|jjj�n
|j|�dS)Nr2rsr�z unexpected-hidden-input-in-table)	rjrrIr|r<r�r{r+r)r@r�r)r)r*r��sz-getPhases.<locals>.InTablePhase.startTagInputcSsD|jjd�|jjdkr@|jj|�|jjd|j_|jjj�dS)Nzunexpected-form-in-tabler	ry)rIr|r<r�r�r{r+)r@r�r)r)r*r��s
z,getPhases.<locals>.InTablePhase.startTagFormcSs<|jjdd|di�d|j_|jjdj|�d|j_dS)Nz)unexpected-start-tag-implies-table-voodoor>Tr�F)rIr|r<r�rFr�)r@r�r)r)r*r�sz-getPhases.<locals>.InTablePhase.startTagOthercSs�|jjddd�r�|jj�|jjdjdkrJ|jjdd|jjdjd��x"|jjdjdkrl|jjj�qLW|jjj�|jj�n|jj	s�t
�|jj�dS)	Nr�)r�r	zend-tag-too-early-named)r�r�ryryry)r<r�r�r{r>rIr|r+r_rPr�)r@r�r)r)r*r��s
z+getPhases.<locals>.InTablePhase.endTagTablecSs|jjdd|di�dS)Nzunexpected-end-tagr>)rIr|)r@r�r)r)r*r��sz,getPhases.<locals>.InTablePhase.endTagIgnorecSs<|jjdd|di�d|j_|jjdj|�d|j_dS)Nz'unexpected-end-tag-implies-table-voodoor>Tr�F)rIr|r<r�rFr�)r@r�r)r)r*r�sz+getPhases.<locals>.InTablePhase.endTagOtherN)r7r8r9rHr�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�rr))r�r)r*�InTablePhaseYs&	
r�csPeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)z#getPhases.<locals>.InTableTextPhasecs�j|||�d|_g|_dS)N)rHr��characterTokens)r@rIr<)r�r)r*rH�sz,getPhases.<locals>.InTableTextPhase.__init__cSsddjdd�|jD��}tdd�|D��rJtd|d�}|jjdj|�n|rZ|jj|�g|_dS)Nr�cSsg|]}|d�qS)rsr))r=r�r)r)r*rA�szGgetPhases.<locals>.InTableTextPhase.flushCharacters.<locals>.<listcomp>cSsg|]}|tk�qSr))r)r=r�r)r)r*rA�srn)r2rsr�)�joinr�r�rrIrFr�r<)r@rsr�r)r)r*�flushCharacters�sz3getPhases.<locals>.InTableTextPhase.flushCharacterscSs|j�|j|j_|S)N)r�r�rIr])r@r�r)r)r*r��s
z2getPhases.<locals>.InTableTextPhase.processCommentcSs|j�|j|j_dS)NT)r�r�rIr])r@r)r)r*r��s
z.getPhases.<locals>.InTableTextPhase.processEOFcSs |ddkrdS|jj|�dS)Nrsr�)r�r�)r@r�r)r)r*r�sz5getPhases.<locals>.InTableTextPhase.processCharacterscSs|jj|�dS)N)r�r�)r@r�r)r)r*r�sz:getPhases.<locals>.InTableTextPhase.processSpaceCharacterscSs|j�|j|j_|S)N)r�r�rIr])r@r�r)r)r*r�
s
z3getPhases.<locals>.InTableTextPhase.processStartTagcSs|j�|j|j_|S)N)r�r�rIr])r@r�r)r)r*r�s
z1getPhases.<locals>.InTableTextPhase.processEndTagN)r7r8r9rHr�r�r�r�r�r�r�r))r�r)r*�InTableTextPhase�s	r�cs`eZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)z!getPhases.<locals>.InCaptionPhasec
sf�j|||�tjd|jfd
|jfg�|_|j|j_tjd|jfd|j	fd|j
fg�|_|j|j_dS)Nr�r�rzr�r�r�r�r�r�r�r�r�)	r�rzr�r�r�r�r�r�r�)
r�rzr�r�r�r�r�r�r�r�)
rHrrr��startTagTableElementr�rr�
endTagCaptionr�r�r�r)r@rIr<)r�r)r*rHs
z*getPhases.<locals>.InCaptionPhase.__init__cSs|jjddd�S)Nr�r�)r�)r<r�)r@r)r)r*�ignoreEndTagCaption+sz5getPhases.<locals>.InCaptionPhase.ignoreEndTagCaptioncSs|jjdj�dS)Nr�)rIrFr�)r@r)r)r*r�.sz,getPhases.<locals>.InCaptionPhase.processEOFcSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r�1sz3getPhases.<locals>.InCaptionPhase.processCharacterscSs0|jj�|j�}|jjjtd��|s,|SdS)Nr�)rIr|r�r]r�r
)r@r��ignoreEndTagr)r)r*r�4s

z6getPhases.<locals>.InCaptionPhase.startTagTableElementcSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r<sz/getPhases.<locals>.InCaptionPhase.startTagOthercSs�|j�s�|jj�|jjdjdkrB|jjdd|jjdjd��x"|jjdjdkrd|jjj�qDW|jjj�|jj�|jj	d|j_
n|jjs�t�|jj�dS)	Nr	r�z$expected-one-end-tag-but-got-another)r�r�r�ryryry)
r�r<r�r{r>rIr|r+r�rFr]rPr�)r@r�r)r)r*r�?s

z/getPhases.<locals>.InCaptionPhase.endTagCaptioncSs0|jj�|j�}|jjjtd��|s,|SdS)Nr�)rIr|r�r]r�r
)r@r�r�r)r)r*r�Qs

z-getPhases.<locals>.InCaptionPhase.endTagTablecSs|jjdd|di�dS)Nzunexpected-end-tagr>)rIr|)r@r�r)r)r*r�Xsz.getPhases.<locals>.InCaptionPhase.endTagIgnorecSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r[sz-getPhases.<locals>.InCaptionPhase.endTagOtherN)
r7r8r9rHr�r�r�r�rr�r�r�rr))r�r)r*�InCaptionPhasesr�csXeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)z%getPhases.<locals>.InColumnGroupPhasecs^�j|||�tjd|jfd|jfg�|_|j|j_tjd|jfd|j	fg�|_
|j|j
_dS)Nr�rzr�)rHrrr�r�r�rr�endTagColgroup�	endTagColr�r)r@rIr<)r�r)r*rHas
z.getPhases.<locals>.InColumnGroupPhase.__init__cSs|jjdjdkS)Nr	r�ry)r<r{r>)r@r)r)r*�ignoreEndTagColgrouppsz:getPhases.<locals>.InColumnGroupPhase.ignoreEndTagColgroupcSsD|jjdjdkr"|jjst�dS|j�}|jtd��|s@dSdS)Nr	r�r�Try)	r<r{r>rIrPr�r�r�r
)r@r�r)r)r*r�ssz0getPhases.<locals>.InColumnGroupPhase.processEOFcSs"|j�}|jtd��|s|SdS)Nr�)r�r�r
)r@r�r�r)r)r*r�}sz7getPhases.<locals>.InColumnGroupPhase.processCharacterscSs$|jj|�|jjj�d|d<dS)NTrx)r<r�r{r+)r@r�r)r)r*r��sz1getPhases.<locals>.InColumnGroupPhase.startTagColcSs"|j�}|jtd��|s|SdS)Nr�)r�r�r
)r@r�r�r)r)r*r�sz3getPhases.<locals>.InColumnGroupPhase.startTagOthercSs@|j�r |jjst�|jj�n|jjj�|jjd|j_	dS)Nr�)
r�rIrPr�r|r<r{r+rFr])r@r�r)r)r*r��s
z4getPhases.<locals>.InColumnGroupPhase.endTagColgroupcSs|jjdddi�dS)Nz
no-end-tagr>rz)rIr|)r@r�r)r)r*r��sz/getPhases.<locals>.InColumnGroupPhase.endTagColcSs"|j�}|jtd��|s|SdS)Nr�)r�r�r
)r@r�r�r)r)r*r�sz1getPhases.<locals>.InColumnGroupPhase.endTagOtherN)r7r8r9rHr�r�r�r�rr�r�rr))r�r)r*�InColumnGroupPhase^s
	r�csxeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)z#getPhases.<locals>.InTableBodyPhasecsv�j|||�tjd|jfd|jfd
|jfd|jfg�|_|j|j_	tjd|j
fd|jfd|jfg�|_
|j|j
_	dS)Nr�r�r�r�r�rzr�r�r�r�r�r�)r�r�)r�rzr�r�r�r�)r�r�r�)r�r�rzr�r�r�r�r�)rHrrr��
startTagTr�startTagTableCell�startTagTableOtherr�rr�endTagTableRowGroupr�r�r�r)r@rIr<)r�r)r*rH�s
z,getPhases.<locals>.InTableBodyPhase.__init__cSsFx"|jjdjdkr"|jjj�qW|jjdjdkrB|jjsBt�dS)	Nr	r�r�r�r�ry)r�r�r�r�ry)r<r{r>r+rIrPr�)r@r)r)r*�clearStackToTableBodyContext�s
z@getPhases.<locals>.InTableBodyPhase.clearStackToTableBodyContextcSs|jjdj�dS)Nr�)rIrFr�)r@r)r)r*r��sz.getPhases.<locals>.InTableBodyPhase.processEOFcSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r��sz:getPhases.<locals>.InTableBodyPhase.processSpaceCharacterscSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r��sz5getPhases.<locals>.InTableBodyPhase.processCharacterscSs(|j�|jj|�|jjd|j_dS)Nr�)r�r<r�rIrFr])r@r�r)r)r*r��sz.getPhases.<locals>.InTableBodyPhase.startTagTrcSs*|jjdd|di�|jtdd��|S)Nzunexpected-cell-in-table-bodyr>r�ro)rIr|r�r
)r@r�r)r)r*r��sz5getPhases.<locals>.InTableBodyPhase.startTagTableCellcSsn|jjddd�s0|jjddd�s0|jjddd�rT|j�|jt|jjdj��|S|jjs`t	�|jj
�dS)Nr�r�)r�r�r�r	ry)r<r�r�r�r
r{r>rIrPr�r|)r@r�r)r)r*r��sz6getPhases.<locals>.InTableBodyPhase.startTagTableOthercSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r�sz1getPhases.<locals>.InTableBodyPhase.startTagOthercSsT|jj|ddd�r:|j�|jjj�|jjd|j_n|jjdd|di�dS)Nr>r�)r�r�z unexpected-end-tag-in-table-body)	r<r�r�r{r+rIrFr]r|)r@r�r)r)r*r��sz7getPhases.<locals>.InTableBodyPhase.endTagTableRowGroupcSsn|jjddd�s0|jjddd�s0|jjddd�rT|j�|jt|jjdj��|S|jjs`t	�|jj
�dS)Nr�r�)r�r�r�r	ry)r<r�r�r�r
r{r>rIrPr�r|)r@r�r)r)r*r��sz/getPhases.<locals>.InTableBodyPhase.endTagTablecSs|jjdd|di�dS)Nz unexpected-end-tag-in-table-bodyr>)rIr|)r@r�r)r)r*r��sz0getPhases.<locals>.InTableBodyPhase.endTagIgnorecSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r�sz/getPhases.<locals>.InTableBodyPhase.endTagOtherN)r7r8r9rHr�r�r�r�r�r�r�rr�r�r�rr))r�r)r*�InTableBodyPhase�s
	
r�cs�eZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)zgetPhases.<locals>.InRowPhasecsv�j|||�tjd|jfd
|jfd|jfg�|_|j|j_tjd
|j	fd|j
fd|jfd|jfg�|_
|j|j
_dS)Nr�r�r�r�rzr�r�r�r�r�r�r�)r�r�)r�rzr�r�r�r�r�)r�r�r�)r�r�rzr�r�r�r�)rHrrr�r�r�r�rr�endTagTrr�r�r�r�r)r@rIr<)r�r)r*rHs
z&getPhases.<locals>.InRowPhase.__init__cSsDx>|jjdjdkr>|jjdd|jjdji�|jjj�qWdS)	Nr	r�r�z'unexpected-implied-end-tag-in-table-rowr>ry)r�r�ry)r<r{r>rIr|r+)r@r)r)r*�clearStackToTableRowContextsz9getPhases.<locals>.InRowPhase.clearStackToTableRowContextcSs|jjddd�S)Nr�r�)r�)r<r�)r@r)r)r*�ignoreEndTagTrsz,getPhases.<locals>.InRowPhase.ignoreEndTagTrcSs|jjdj�dS)Nr�)rIrFr�)r@r)r)r*r�"sz(getPhases.<locals>.InRowPhase.processEOFcSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r�%sz4getPhases.<locals>.InRowPhase.processSpaceCharacterscSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r�(sz/getPhases.<locals>.InRowPhase.processCharacterscSs6|j�|jj|�|jjd|j_|jjjt�dS)Nr�)	r�r<r�rIrFr]r�r�r
)r@r�r)r)r*r�+sz/getPhases.<locals>.InRowPhase.startTagTableCellcSs"|j�}|jtd��|s|SdS)Nr�)r�r�r
)r@r�r�r)r)r*r�1sz0getPhases.<locals>.InRowPhase.startTagTableOthercSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r8sz+getPhases.<locals>.InRowPhase.startTagOthercSsH|j�s.|j�|jjj�|jjd|j_n|jjs:t	�|jj
�dS)Nr�)r�r�r<r{r+rIrFr]rPr�r|)r@r�r)r)r*r�;sz&getPhases.<locals>.InRowPhase.endTagTrcSs"|j�}|jtd��|s|SdS)Nr�)r�r�r
)r@r�r�r)r)r*r�Esz)getPhases.<locals>.InRowPhase.endTagTablecSs4|jj|ddd�r&|jtd��|S|jj�dS)Nr>r�)r�r�)r<r�r�r
rIr|)r@r�r)r)r*r�Msz1getPhases.<locals>.InRowPhase.endTagTableRowGroupcSs|jjdd|di�dS)Nzunexpected-end-tag-in-table-rowr>)rIr|)r@r�r)r)r*r�Tsz*getPhases.<locals>.InRowPhase.endTagIgnorecSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*rXsz)getPhases.<locals>.InRowPhase.endTagOtherN)r7r8r9rHr�r�r�r�r�r�r�rr�r�r�r�rr))r�r)r*�
InRowPhases
r�cs`eZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)zgetPhases.<locals>.InCellPhasecsf�j|||�tjd|jfd
|jfg�|_|j|j_tjd|jfd|j	fd|j
fg�|_|j|j_dS)Nr�r�rzr�r�r�r�r�r�r�r�r�)	r�rzr�r�r�r�r�r�r�)r�r�)r�r�rzr�r�)r�r�r�r�r�)
rHrrr�r�r�rr�endTagTableCellr��endTagImplyr�r)r@rIr<)r�r)r*rH]s
z'getPhases.<locals>.InCellPhase.__init__cSsB|jjddd�r |jtd��n|jjddd�r>|jtd��dS)Nr�r�)r�r�)r<r�r�r
)r@r)r)r*�	closeCellnsz(getPhases.<locals>.InCellPhase.closeCellcSs|jjdj�dS)Nr�)rIrFr�)r@r)r)r*r�usz)getPhases.<locals>.InCellPhase.processEOFcSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r�xsz0getPhases.<locals>.InCellPhase.processCharacterscSsF|jjddd�s |jjddd�r,|j�|S|jjs8t�|jj�dS)Nr�r�)r�r�)r<r�r�rIrPr�r|)r@r�r)r)r*r�{sz1getPhases.<locals>.InCellPhase.startTagTableOthercSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r�sz,getPhases.<locals>.InCellPhase.startTagOthercSs�|jj|ddd�r�|jj|d�|jjdj|dkrt|jjdd|di�x.|jjj�}|j|dkrRPqRWn|jjj�|jj�|jj	d|j_
n|jjdd|di�dS)	Nr>r�)r�r	zunexpected-cell-end-tagr�zunexpected-end-tagry)r<r�r�r{r>rIr|r+r�rFr])r@r�r�r)r)r*r��s
z.getPhases.<locals>.InCellPhase.endTagTableCellcSs|jjdd|di�dS)Nzunexpected-end-tagr>)rIr|)r@r�r)r)r*r��sz+getPhases.<locals>.InCellPhase.endTagIgnorecSs.|jj|ddd�r |j�|S|jj�dS)Nr>r�)r�)r<r�r�rIr|)r@r�r)r)r*r��sz*getPhases.<locals>.InCellPhase.endTagImplycSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r�sz*getPhases.<locals>.InCellPhase.endTagOtherN)
r7r8r9rHr�r�r�r�rr�r�r�rr))r�r)r*�InCellPhase[s
r�csxeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)z getPhases.<locals>.InSelectPhasecs��j|||�tjd|jfd|jfd|jfd|jfd	|jfd|jfg�|_	|j
|j	_tjd|jfd|j
fd|jfg�|_|j|j_dS)
Nr�rxryr�rprkrtr)rprkrt)rHrrr��startTagOption�startTagOptgroupr�r�r&r�rr�endTagOption�endTagOptgroup�endTagSelectr�r)r@rIr<)r�r)r*rH�s
z)getPhases.<locals>.InSelectPhase.__init__cSs0|jjdjdkr |jjd�n|jjs,t�dS)Nr	r�z
eof-in-selectry)r<r{r>rIr|rPr�)r@r)r)r*r��sz+getPhases.<locals>.InSelectPhase.processEOFcSs$|ddkrdS|jj|d�dS)Nrsr�)r<r�)r@r�r)r)r*r��sz2getPhases.<locals>.InSelectPhase.processCharacterscSs.|jjdjdkr|jjj�|jj|�dS)Nr	rxry)r<r{r>r+r�)r@r�r)r)r*r��sz/getPhases.<locals>.InSelectPhase.startTagOptioncSsL|jjdjdkr|jjj�|jjdjdkr<|jjj�|jj|�dS)Nr	rxryryry)r<r{r>r+r�)r@r�r)r)r*r��s
z1getPhases.<locals>.InSelectPhase.startTagOptgroupcSs|jjd�|jtd��dS)Nzunexpected-select-in-selectr�)rIr|r�r
)r@r�r)r)r*r��sz/getPhases.<locals>.InSelectPhase.startTagSelectcSs>|jjd�|jjddd�r.|jtd��|S|jjs:t�dS)Nzunexpected-input-in-selectr�)r�)rIr|r<r�r�r
rPr�)r@r�r)r)r*r��s
z.getPhases.<locals>.InSelectPhase.startTagInputcSs|jjdj|�S)Nr)rIrFr�)r@r�r)r)r*r&�sz/getPhases.<locals>.InSelectPhase.startTagScriptcSs|jjdd|di�dS)Nzunexpected-start-tag-in-selectr>)rIr|)r@r�r)r)r*r�sz.getPhases.<locals>.InSelectPhase.startTagOthercSs6|jjdjdkr |jjj�n|jjdddi�dS)Nr	rxzunexpected-end-tag-in-selectr>ry)r<r{r>r+rIr|)r@r�r)r)r*r��sz-getPhases.<locals>.InSelectPhase.endTagOptioncSsf|jjdjdkr0|jjdjdkr0|jjj�|jjd	jdkrP|jjj�n|jjdddi�dS)
Nr	rxr�ryzunexpected-end-tag-in-selectr>ry���ry)r<r{r>r+rIr|)r@r�r)r)r*r��sz/getPhases.<locals>.InSelectPhase.endTagOptgroupcSs^|jjddd�rD|jjj�}x|jdkr6|jjj�}qW|jj�n|jjsPt�|jj	�dS)Nr�)r�)
r<r�r{r+r>rIr_rPr�r|)r@r�r�r)r)r*r��sz-getPhases.<locals>.InSelectPhase.endTagSelectcSs|jjdd|di�dS)Nzunexpected-end-tag-in-selectr>)rIr|)r@r�r)r)r*r	sz,getPhases.<locals>.InSelectPhase.endTagOtherN)r7r8r9rHr�r�r�r�r�r�r&rr�r�r�rr))r�r)r*�
InSelectPhase�s
r�csHeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)z'getPhases.<locals>.InSelectInTablePhasec	sN�j|||�tjd	|jfg�|_|j|j_tjd
|jfg�|_|j	|j_dS)Nr�r�r�r�r�r�r�r�)r�r�r�r�r�r�r�r�)r�r�r�r�r�r�r�r�)
rHrrr�r�rrr�r�r)r@rIr<)r�r)r*rH	s
z0getPhases.<locals>.InSelectInTablePhase.__init__cSs|jjdj�dS)Nr�)rIrFr�)r@r)r)r*r�	sz2getPhases.<locals>.InSelectInTablePhase.processEOFcSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r�	sz9getPhases.<locals>.InSelectInTablePhase.processCharacterscSs(|jjdd|di�|jtd��|S)Nz5unexpected-table-element-start-tag-in-select-in-tabler>r�)rIr|rr
)r@r�r)r)r*r�!	sz5getPhases.<locals>.InSelectInTablePhase.startTagTablecSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r&	sz5getPhases.<locals>.InSelectInTablePhase.startTagOthercSs@|jjdd|di�|jj|ddd�r<|jtd��|SdS)Nz3unexpected-table-element-end-tag-in-select-in-tabler>r�)r�r�)rIr|r<r�rr
)r@r�r)r)r*r�)	sz3getPhases.<locals>.InSelectInTablePhase.endTagTablecSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r/	sz3getPhases.<locals>.InSelectInTablePhase.endTagOtherN)
r7r8r9rHr�r�r�rr�rr))r�r)r*�InSelectInTablePhase	sr�c-s�eZdZeddddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,g,�Z�fd-d.�Zd/d0�Z�fd1d2�Zd3d4�Zd5d6�Z	d7S)8z(getPhases.<locals>.InForeignContentPhaserWrXr>r�rr?rYrTr+rBrUrZriZh1Zh2Zh3Zh4Zh5Zh6r�rqr\rjrSrQrJr4rcrLr(rPr�r]r^�spanr`r_�subZsupr�rarbrO�varcs�j|||�dS)N)rH)r@rIr<)r�r)r*rH<	sz1getPhases.<locals>.InForeignContentPhase.__init__c%Ssnddddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%�$}|d&|krj||d&|d&<dS)'NZaltGlyphZaltGlyphDefZaltGlyphItemZanimateColorZ
animateMotionZanimateTransformZclipPathZfeBlendZ
feColorMatrixZfeComponentTransferZfeCompositeZfeConvolveMatrixZfeDiffuseLightingZfeDisplacementMapZfeDistantLightZfeFloodZfeFuncAZfeFuncBZfeFuncGZfeFuncRZfeGaussianBlurZfeImageZfeMergeZfeMergeNodeZfeMorphologyZfeOffsetZfePointLightZfeSpecularLightingZfeSpotLightZfeTileZfeTurbulenceZ
foreignObjectZglyphRefZlinearGradientZradialGradientZtextPath)$ZaltglyphZaltglyphdefZaltglyphitemZanimatecolorZ
animatemotionZanimatetransformZclippathZfeblendZ
fecolormatrixZfecomponenttransferZfecompositeZfeconvolvematrixZfediffuselightingZfedisplacementmapZfedistantlightZfefloodZfefuncaZfefuncbZfefuncgZfefuncrZfegaussianblurZfeimageZfemergeZfemergenodeZfemorphologyZfeoffsetZfepointlightZfespecularlightingZfespotlightZfetileZfeturbulenceZ
foreignobjectZglyphrefZlineargradientZradialgradientZtextpathr>r))r@r��replacementsr)r)r*�adjustSVGTagNames?	sLz:getPhases.<locals>.InForeignContentPhase.adjustSVGTagNamescsL|ddkrd|d<n&|jjr<tdd�|dD��r<d|j_�j||�dS)Nrsr�u�css|]}|tkVqdS)N)r)r=r�r)r)r*r�l	szMgetPhases.<locals>.InForeignContentPhase.processCharacters.<locals>.<genexpr>F)rIr`r�r�)r@r�)r�r)r*r�h	s
z:getPhases.<locals>.InForeignContentPhase.processCharacterscSs6|jjd}|d|jksD|ddkr�t|dj��tdddg�@r�|jjdd|di�xR|jjdj|jjkr�|jj	|jjd�r�|jj
|jjd�r�|jjj�q\W|S|jtd	kr�|jj
|�n$|jtd
kr�|j|�|jj|�|jj|�|j|d<|jj|�|d�r2|jjj�d
|d<dS)Nr	r>r[rsZcolorZface�sizez*unexpected-html-element-in-foreign-contentrdrurhrwTrxryryryry)r<r{�breakoutElements�set�keysrIr|rhrrlrmr+rrrrrr�)r@r�r�r)r)r*r�p	s.



z8getPhases.<locals>.InForeignContentPhase.processStartTagcSs�t|jj�d}|jjd}|jjt�|dkrF|jjdd|di�x�|jjt�|dkr�|jj|jj	dkr�|jjj
�|jjj|j_x |jjj�|kr�|jjs�t
�q�Wd}P|d8}|jj|}|j|jjkr�qHqH|jjj|�}PqHW|S)Nr	r>zunexpected-end-tagr�ry)r~r<r{r>rjrrIr|r]rFr�r�r+r�rhrr�)r@r�Z	nodeIndexr�r�r)r)r*r��	s(z6getPhases.<locals>.InForeignContentPhase.processEndTagN)
r7r8r9r�rrHrr�r�r�r))r�r)r*�InForeignContentPhase2	s


)rcsPeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)z!getPhases.<locals>.AfterBodyPhasecsN�j|||�tjd|jfg�|_|j|j_tjd|jfg�|_|j	|j_dS)Nr�)
rHrrr�r�rrr�r�r)r@rIr<)r�r)r*rH�	s
z*getPhases.<locals>.AfterBodyPhase.__init__cSsdS)Nr))r@r)r)r*r��	sz,getPhases.<locals>.AfterBodyPhase.processEOFcSs|jj||jjd�dS)Nr)r<r�r{)r@r�r)r)r*r��	sz0getPhases.<locals>.AfterBodyPhase.processCommentcSs |jjd�|jjd|j_|S)Nzunexpected-char-after-bodyr�)rIr|rFr])r@r�r)r)r*r��	sz3getPhases.<locals>.AfterBodyPhase.processCharacterscSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r��	sz.getPhases.<locals>.AfterBodyPhase.startTagHtmlcSs*|jjdd|di�|jjd|j_|S)Nzunexpected-start-tag-after-bodyr>r�)rIr|rFr])r@r�r)r)r*r�	sz/getPhases.<locals>.AfterBodyPhase.startTagOthercSs*|jjr|jjd�n|jjd|j_dS)Nz'unexpected-end-tag-after-body-innerhtml�afterAfterBody)rIrPr|rFr])r@r>r)r)r*r��	sz,getPhases.<locals>.AfterBodyPhase.endTagHtmlcSs*|jjdd|di�|jjd|j_|S)Nzunexpected-end-tag-after-bodyr>r�)rIr|rFr])r@r�r)r)r*r�	sz-getPhases.<locals>.AfterBodyPhase.endTagOtherN)r7r8r9rHr�r�r�r�rr�rr))r�r)r*�AfterBodyPhase�	sr
csXeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)z"getPhases.<locals>.InFramesetPhasecsf�j|||�tjd|jfd|jfd|jfd|jfg�|_|j|j_	tjd|j
fg�|_|j|j_	dS)Nr�r�r{r)
rHrrr�r7�
startTagFrame�startTagNoframesr�rr�endTagFramesetr�r)r@rIr<)r�r)r*rH�	s
z+getPhases.<locals>.InFramesetPhase.__init__cSs0|jjdjdkr |jjd�n|jjs,t�dS)Nr	r�zeof-in-framesetry)r<r{r>rIr|rPr�)r@r)r)r*r��	sz-getPhases.<locals>.InFramesetPhase.processEOFcSs|jjd�dS)Nzunexpected-char-in-frameset)rIr|)r@r�r)r)r*r��	sz4getPhases.<locals>.InFramesetPhase.processCharacterscSs|jj|�dS)N)r<r�)r@r�r)r)r*r7�	sz3getPhases.<locals>.InFramesetPhase.startTagFramesetcSs|jj|�|jjj�dS)N)r<r�r{r+)r@r�r)r)r*r�	sz0getPhases.<locals>.InFramesetPhase.startTagFramecSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r�	sz3getPhases.<locals>.InFramesetPhase.startTagNoframescSs|jjdd|di�dS)Nz unexpected-start-tag-in-framesetr>)rIr|)r@r�r)r)r*r�	sz0getPhases.<locals>.InFramesetPhase.startTagOthercSs\|jjdjdkr |jjd�n|jjj�|jjrX|jjdjdkrX|jjd|j_dS)Nr	r�z)unexpected-frameset-in-frameset-innerhtmlr��
afterFramesetryry)	r<r{r>rIr|r+rPrFr])r@r�r)r)r*r
�	s
z1getPhases.<locals>.InFramesetPhase.endTagFramesetcSs|jjdd|di�dS)Nzunexpected-end-tag-in-framesetr>)rIr|)r@r�r)r)r*r	
sz.getPhases.<locals>.InFramesetPhase.endTagOtherN)r7r8r9rHr�r�r7rrrr
rr))r�r)r*�InFramesetPhase�	srcsHeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)z%getPhases.<locals>.AfterFramesetPhasecsV�j|||�tjd|jfd|jfg�|_|j|j_tjd|jfg�|_	|j
|j	_dS)Nr�r)rHrrr�rr�rrr�r�r)r@rIr<)r�r)r*rH
s
z.getPhases.<locals>.AfterFramesetPhase.__init__cSsdS)Nr))r@r)r)r*r�
sz0getPhases.<locals>.AfterFramesetPhase.processEOFcSs|jjd�dS)Nzunexpected-char-after-frameset)rIr|)r@r�r)r)r*r�!
sz7getPhases.<locals>.AfterFramesetPhase.processCharacterscSs|jjdj|�S)Nr)rIrFr�)r@r�r)r)r*r$
sz6getPhases.<locals>.AfterFramesetPhase.startTagNoframescSs|jjdd|di�dS)Nz#unexpected-start-tag-after-framesetr>)rIr|)r@r�r)r)r*r'
sz3getPhases.<locals>.AfterFramesetPhase.startTagOthercSs|jjd|j_dS)N�afterAfterFrameset)rIrFr])r@r�r)r)r*r�+
sz0getPhases.<locals>.AfterFramesetPhase.endTagHtmlcSs|jjdd|di�dS)Nz!unexpected-end-tag-after-framesetr>)rIr|)r@r�r)r)r*r.
sz1getPhases.<locals>.AfterFramesetPhase.endTagOtherN)
r7r8r9rHr�r�rrr�rr))r�r)r*�AfterFramesetPhase
srcsPeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)z&getPhases.<locals>.AfterAfterBodyPhasecs0�j|||�tjd|jfg�|_|j|j_dS)Nr�)rHrrr�r�rr)r@rIr<)r�r)r*rH3
sz/getPhases.<locals>.AfterAfterBodyPhase.__init__cSsdS)Nr))r@r)r)r*r�;
sz1getPhases.<locals>.AfterAfterBodyPhase.processEOFcSs|jj||jj�dS)N)r<r�r�)r@r�r)r)r*r�>
sz5getPhases.<locals>.AfterAfterBodyPhase.processCommentcSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r�A
sz=getPhases.<locals>.AfterAfterBodyPhase.processSpaceCharacterscSs |jjd�|jjd|j_|S)Nzexpected-eof-but-got-charr�)rIr|rFr])r@r�r)r)r*r�D
sz8getPhases.<locals>.AfterAfterBodyPhase.processCharacterscSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r�I
sz3getPhases.<locals>.AfterAfterBodyPhase.startTagHtmlcSs*|jjdd|di�|jjd|j_|S)Nzexpected-eof-but-got-start-tagr>r�)rIr|rFr])r@r�r)r)r*rL
sz4getPhases.<locals>.AfterAfterBodyPhase.startTagOthercSs*|jjdd|di�|jjd|j_|S)Nzexpected-eof-but-got-end-tagr>r�)rIr|rFr])r@r�r)r)r*r�R
sz4getPhases.<locals>.AfterAfterBodyPhase.processEndTagN)r7r8r9rHr�r�r�r�r�rr�r))r�r)r*�AfterAfterBodyPhase2
srcsXeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)z*getPhases.<locals>.AfterAfterFramesetPhasecs8�j|||�tjd|jfd|jfg�|_|j|j_dS)Nr�r)rHrrr��startTagNoFramesr�rr)r@rIr<)r�r)r*rHY
s
z3getPhases.<locals>.AfterAfterFramesetPhase.__init__cSsdS)Nr))r@r)r)r*r�b
sz5getPhases.<locals>.AfterAfterFramesetPhase.processEOFcSs|jj||jj�dS)N)r<r�r�)r@r�r)r)r*r�e
sz9getPhases.<locals>.AfterAfterFramesetPhase.processCommentcSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r�h
szAgetPhases.<locals>.AfterAfterFramesetPhase.processSpaceCharacterscSs|jjd�dS)Nzexpected-eof-but-got-char)rIr|)r@r�r)r)r*r�k
sz<getPhases.<locals>.AfterAfterFramesetPhase.processCharacterscSs|jjdj|�S)Nr�)rIrFr�)r@r�r)r)r*r�n
sz7getPhases.<locals>.AfterAfterFramesetPhase.startTagHtmlcSs|jjdj|�S)Nr)rIrFr�)r@r�r)r)r*rq
sz;getPhases.<locals>.AfterAfterFramesetPhase.startTagNoFramescSs|jjdd|di�dS)Nzexpected-eof-but-got-start-tagr>)rIr|)r@r�r)r)r*rt
sz8getPhases.<locals>.AfterAfterFramesetPhase.startTagOthercSs|jjdd|di�dS)Nzexpected-eof-but-got-end-tagr>)rIr|)r@r�r)r)r*r�x
sz8getPhases.<locals>.AfterAfterFramesetPhase.processEndTagN)r7r8r9rHr�r�r�r�r�rrr�r))r�r)r*�AfterAfterFramesetPhaseX
s	r)rTrSr�rr/r0r�r�r�r�r�r�r�r�r�r�r�rvr�r�rr	r)r)rGrVr�rrrr1r5r:r�r�r�r�r�r�r�r�r�r�r�rr
rrrrr))r�r*rE_sp)#.g@CX!-GBbYLd's/9%&&rEcs^ts
tjr t|d�t��@}nt|d�t��@}|rZt�fdd�|dj�D��|d<dS)Nrsc3s"|]\}}�j||�|fVqdS)N)r})r=�k�v)rr)r*r��
sz$adjust_attributes.<locals>.<genexpr>)rrZPY27rr�rr.)r�rZneeds_adjustmentr))rr*r��
s
r�rpFcCs|dkri}t||||d�S)N)r2r>rsrw)r)r>r2rirwr)r)r*r
�
s
r
c@seZdZdZdS)rrzError in parsed documentN)r7r8r9r�r)r)r)r*rr�
srr)rT)r+rT)rpNF)1Z
__future__rrrZsixrrrr0�collectionsr�ImportErrorZordereddictr�r
rrZtreebuilders.baser
rZ	constantsrrrrrrrrrrrrr�rrrrr#r-r;rgr"ZmemoizerEr�r
�	Exceptionrrr)r)r)r*�<module>sRH

)L



Youez - 2016 - github.com/yon3zu
LinuXploit