File: //usr/local/lib/python3.6/site-packages/feedparser/__pycache__/sanitizer.cpython-36.pyc
3
_9j0] � @ sj d dl Z ddlmZ ddlmZ G dd� de�Zdd� Ze jd e j�Z e jd
e j�Z
e jd�Zdd
� ZdS )� N� )�_BaseHTMLProcessor)�make_safe_absolute_uric � s� e Zd Zddddddddd d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcddhdZddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~ddd�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�dd�d�d�d�d�d�d�d(d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d7d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�dRd�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�h�Zd�d�d�hZd�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d&d�d�d�d�d�d��d �d�d�d�d�d�d�d�d�d �d
�d�d�d
�d�d�d�d�d�d�dd�dd�h.Z�d�d�d�d�d�d�d�d�d�dd�d �d!�d"�d#�d$�d%�d&�d'�d(�d)�d*�d+�d,�d-d��d.�d/�d0�d1�d2�d3�d4�d5�d6�d7�d8�d9�d:h'Zej �d;�Z
�d<�d=�d>�d?�d@�dA�dB�dC�dD�dE�dF�dG�dH�dI�dJ�dK�dL�dM�dN�dO�dP�dQ�dR�dS�dT�dU�dV�dW�dX�dY�dZ�d[�d\�d]�d^�d_�d`�da�db�dc�dd�de�d,�dfh,Z�dg�dh�didi�dj�dk�dl�dm�dn�do�dp�dq�dr�ds�dt�du�dv�dw�dx�dy�dz�d{dd��d|�d}�d~�d�d��d��d��d�d(d��d��d�d�d�d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d��d�d��d��d�d��d��d��d�dΐd��d��d��d��d��d��d��d��d��d�dԐd��d��d��d��d��d�d�d��d��d��d��d�hcZd�d��d��d��d��d��ddÐdĐdŐdƐdǐdȐdɐdʐdːd̐d͐dΐdϐdАdѐdҐdӐdԐdՐddאdؐdِdڐd�dݐdܐd�h#Z
�dސdߐd�d�d�d�d�d�d�d�d�d�d�d�d�d��d�d�d�d�d�d�d��d�d�d�d��d��d��d�d�d��d�d�d�d��d��d��d��d��d��d��d��d d��d�dd��d�d�d�d�dd��d�d �d
�d�d�d
�dd�d�d��d�d�d�d�d�d�d�dҐd�d�d�d�d�d�d�d�d�d�d �d!�d"�d#�d$�d%�d&�d'�d(�d)�d*�d+�d,�d-�d.�d/�d0�d1�d2�d3dېd4�d5�d6dߐd7�d8�d9�d:�d;�d<�d=�d>�d?�d@�dAd�dB�dC�dD�dE�dF�dG�dH�d��dI�d��dJ�d��dKd�dL�d��d��dM�dN�dO�dPh�Z�dQZ�dQZ�d��d��d��d+�d.�d/�d1�d2hZ�df� f�dS�dT� Z� f�dU�dV�Z� f�dW�dX�Z� f�dY�dZ�Z�d[�d\� Z�d]�d^� Z� f�d_�d`�Z�da�db� Z�dg� f�dd�de� Z� ZS (h �_HTMLSanitizer�aZabbrZacronym�address�area�article�aside�audio�b�big�
blockquote�br�buttonZcanvas�caption�centerZcite�code�col�colgroup�command�datagridZdatalist�dd�del�details�dfn�dialog�dir�div�dl�dt�emzevent-source�fieldset�
figcaption�figure�font�footer�form�h1�h2�h3�h4�h5�h6�header�hr�i�img�inputZinsZkbd�keygen�labelZlegend�li�m�map�menuZmeterZmulticol�navZnextid�noscript�ol�optgroup�option�output�p�pre�progress�q�sZsamp�section�select�smallZsound�sourceZspacer�span�strike�strong�sub�sup�table�tbody�td�textarea�tfoot�th�thead�time�tr�tt�u�ul�var�video�acceptzaccept-charsetZ accesskey�actionZalignZalt�autocomplete� autofocusZaxis�
backgroundZbalanceZbgcolorZbgproperties�borderZbordercolorZbordercolordarkZbordercolorlightZ
bottompaddingZcellpaddingZcellspacing�ch� challenge�charZcharoff�charset�checkedZchoff�class�clear�color�colsZcolspan�compactZcontenteditable�controlsZcoords�dataZdatafldZdatapagesizeZdatasrc�datetime�default�delay�disabledZ draggableZdynsrcZenctype�end�face�for�frameZ
galleryimgZgutter�headers�height�hiddenZ hidefocus�high�hrefZhreflangZhspaceZicon�idZ inputmode�ismapZkeytype�langZleftspacing�listZlongdesc�loopZ loopcountZloopendZ loopstart�lowZlowsrc�max� maxlengthZmedia�method�min�multiple�nameZnohref�noshadeZnowrap�openZoptimum�patternZpingz
point-sizeZposterZpqgZpreload�promptZ
radiogroup�readonly�relz
repeat-maxz
repeat-min�replace�required�revZrightspacing�rowsZrowspan�rulesZscope�selected�shape�size�src�start�step�style�summary�suppressZtabindex�target�template�titleZ
toppadding�typeZunselectable�urnZusemapZvalign�value�variable�volumeZvrmlZvspace�width�wrapzxml:lang�applet�scriptZazimuthzbackground-colorzborder-bottom-colorzborder-collapsezborder-colorzborder-left-colorzborder-right-colorzborder-top-color�cursor� directionZdisplayZ elevation�floatzfont-familyz font-sizez
font-stylezfont-variantzfont-weightzletter-spacingzline-heightZoverflow�pausezpause-afterzpause-beforeZpitchzpitch-rangeZrichnessZspeakzspeak-headerz
speak-numeralzspeak-punctuationzspeech-rateZstressz
text-alignztext-decorationztext-indentzunicode-bidizvertical-alignzvoice-familyzwhite-spacez
!importantZaqua�auto�black�block�blue�boldZbothZbottomZbrownZcollapseZdashedZdottedZfuchsiaZgray�green�italic�leftZlimeZmaroonZmediumZnavy�none�normalZolive�pointerZpurple�red�rightZsilverZsolidZteal�topZtransparent� underline�white�yellowz\^(#[0-9a-f]+|rgb\(\d+%?,\d*%?,?\d*%?\)?|\d{0,2}\.?\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\))?)$�
annotationzannotation-xmlZmactionZmaligngroup�
malignmark�mathZmencloseZmerrorZmfencedZmfrac�mglyph�miZ
mlabeledtrZmlongdivZ
mmultiscripts�mn�moZmoverZmpaddedZmphantomZmprescriptsZmrootZmrow�msZ mscarriesZmscarryZmsgroupZmslineZmspaceZmsqrtZmsrowZmstackZmstyleZmsubZmsubsupZmsupZmtableZmtd�mtextZmtrZmunderZ
munderoverZ semanticsZaccentZaccentunderZ
actiontypeZalignmentscopeZaltimgz
altimg-heightz
altimg-valignzaltimg-widthZalttextZbevelledZ charalign�closeZcolumnalignZcolumnlinesZ
columnspacingZ
columnspanZcolumnwidthZcrossoutZdecimalpointZ
denomalign�depthZdisplaystyleZedge�encodingZequalcolumnsZ equalrowsZfenceZ fontstyleZ
fontweightZframespacingZ
groupalignZindentalignZindentalignfirstZindentalignlastZindentshiftZindentshiftfirstZindentshiftlastZindenttargetZinfixlinebreakstyleZlargeop�lengthZ linebreakZlinebreakmultcharZlinebreakstyleZlineleadingZ
linethickness�locationZlongdivstyleZlquoteZlspaceZmathbackgroundZ mathcolorZmathsizeZmathvariant�maxsizeZminlabelspacingZminsizeZ
movablelimits�notationZnumalign�other�positionZrowalignZrowlinesZ
rowspacingZrquoteZrspaceZscriptlevelZ
scriptminsizeZscriptsizemultiplierZ selection� separator�
separators�shiftZsideZ
stackalignZstretchyZsubscriptshiftZsuperscriptshiftZ symmetricZvoffsetz
xlink:hrefz
xlink:showz
xlink:type�xmlnszxmlns:xlinkZanimate�animateColor�
animateMotion�animateTransformZcircleZdefs�descZellipsez font-facezfont-face-namez
font-face-src�
foreignObject�gZglyphZhkern�line�linearGradient�marker�metadataz
missing-glyphZmpath�pathZpolygonZpolyline�radialGradientZrect�set�stop�svg�switch�textZtspanZusez
accent-height�
accumulateZadditiveZ
alphabeticzarabic-formZascent�
attributeName�
attributeType�baseProfileZbbox�beginZby�calcModez
cap-heightzcolor-rendering�contentZcx�cy�dZdescentZdurZdxZdy�fillzfill-opacityz fill-rulezfont-stretch�fromZfxZfyZg1Zg2z
glyph-name�
gradientUnitsZhangingzhoriz-adv-xzhoriz-origin-x�ideographic�k� keyPoints�
keySplines�keyTimesz
marker-endz
marker-midzmarker-start�markerHeight�markerUnits�markerWidthZmathematical�offsetZopacityZorient�originzoverline-positionzoverline-thicknesszpanose-1�
pathLengthZpoints�preserveAspectRatio�r�refX�refY�repeatCount� repeatDur�requiredExtensions�requiredFeaturesZrestart�rotate�rxZryZslopeZstemhZstemvz
stop-colorzstop-opacityzstrikethrough-positionzstrikethrough-thicknessZstrokezstroke-dasharrayzstroke-dashoffsetzstroke-linecapzstroke-linejoinzstroke-miterlimitzstroke-opacityzstroke-width�systemLanguageztext-anchorZtoZ transform�u1�u2zunderline-positionzunderline-thickness�unicodez
unicode-rangezunits-per-em�values�version�viewBoxZ
visibilityZwidths�xzx-height�x1Zx2z
xlink:actuatez
xlink:arcrolez
xlink:rolezxlink:titlezxml:basez xml:space�y�y1�y2�
zoomAndPanN�application/xhtml+xmlc s( t t| �j||� d| _d| _d| _d S )Nr )�superr �__init__�unacceptablestack�mathmlOK�svgOK)�selfr� �_type)� __class__� �>/usr/local/lib/python3.6/site-packages/feedparser/sanitizer.pyr � s z_HTMLSanitizer.__init__c s$ t t| �j� d| _d| _d| _d S )Nr )r r �resetr r r )r )r r r r � s z_HTMLSanitizer.resetc
sV | j }i }|| jks| j�r�|| jkr4| jd7 _| jjd�rrt|�jd�sr|dkr`|j d� |dkrr|j d� |dkr�d|kr�| j
d7 _
|dkr�d|kr�| jd7 _| j
r�|| jkr�| j}n�| jo�|| j
k�rp| j�sTdd � | jD �� � fd
d �| jD �}� | _dd� |D �| _d
d � | j
D �� � fdd �| j
D �}� | _
dd� |D �| _| j}| jj||�}| j}n|| jk�r�d S | j
�s�| j�r�tdd� |D ���r�d|k�r�|j d� g }x�| j|�D ]t\}}|dk�rd|k�r| j|�} | �r:|j || f� n6||k�r�|j||�}|dk�r,t|�}|j ||f� �q�W tt| �j||� d S )Nr �htmlr� r� �http://www.w3.org/2000/svgr� �"http://www.w3.org/1998/Math/MathMLc S s g | ]}|j � �qS r )�lower)�.0�attrr r r �
<listcomp> s z3_HTMLSanitizer.unknown_starttag.<locals>.<listcomp>c s g | ]}|� kr|�qS r r )r r )r r r r" s c S s i | ]}||j � �qS r )r )r r r r r �
<dictcomp>
s z3_HTMLSanitizer.unknown_starttag.<locals>.<dictcomp>c S s g | ]}|j � �qS r )r )r r! r r r r" s c s g | ]}|� kr|�qS r r )r r )r r r r"
s c S s i | ]}||j � �qS r )r )r r r r r r# s c s s | ]}|d j d�r|V qdS )r zxlink:N)�
startswith)r r r r r � <genexpr> s z2_HTMLSanitizer.unknown_starttag.<locals>.<genexpr>�xmlns:xlink�http://www.w3.org/1999/xlinkr� ry )r� r )r� r )r� r )r� r )r& r' )r& r' )�acceptable_attributes�acceptable_elementsr �"unacceptable_elements_with_end_tagr r �endswith�dict�get�appendr �mathml_elements�mathml_attributes�svg_elements�svg_attr_map�svg_attributes�svg_elem_map�anyZnormalize_attrs�sanitize_styler r r �unknown_starttag)
r �tag�attrsr( ZkeymapZmixZclean_attrs�keyr� Zclean_value)r )r r r7 � s`
z_HTMLSanitizer.unknown_starttagc s� || j kr�|| jkr"| jd8 _| jrP|| jkrP|dkr�| jr�| jd8 _n@| jr�|| jkr�| jj||�}|dkr�| jr�| jd8 _nd S t t
| �j|� d S )Nr r� r� )r) r* r r r/ r r1 r4 r- r r �unknown_endtag)r r8 )r r r r; * s
z_HTMLSanitizer.unknown_endtagc C s d S )Nr )r r� r r r � handle_pi9 s z_HTMLSanitizer.handle_pic C s d S )Nr )r r� r r r �handle_decl< s z_HTMLSanitizer.handle_declc s | j stt| �j|� d S )N)r r r �handle_data)r r� )r r r r> ? s z_HTMLSanitizer.handle_datac C s t jd�jd|�}t jd|�s"dS t jdd|�j� r8dS g }x�t jd|�D ]�\}}|sXqJ|j� | jkr~|j|d | d � qJ|j d �d
j� dkr�xl|j � D ]}|| j
kr�| jj|� r�P q�W |j|d | d � qJ| jo�|j� | j
krJ|j|d | d � qJW dj|�S )Nzurl\s*\(\s*[^\s)]+?\s*\)\s*� z@^([:,;#%.\sa-zA-Z0-9!]|\w-\w|'[\s\w]+'|"[\s\w]+"|\([\d,\s]+\))*$� z\s*[-\w]+\s*:\s*[^:;]*;?z([-\w]+)\s*:\s*([^:;]*)z: �;�-r r_ r` �margin�padding)r_ r` rC rD )�re�compilerK �match�strip�findallr �acceptable_css_propertiesr. �split�acceptable_css_keywords�valid_css_valuesr �acceptable_svg_properties�join)r r� �clean�propr� �keywordr r r r6 C s(
z_HTMLSanitizer.sanitize_styler c sL t t| �j||�}|dkr|S tjd�j| j|d �}|rB|j� S t| j�S )Nr z--[^>]*>� ) r r �
parse_commentrE rF �search�rawdatarq �len)r r0 �report�retrG )r r r rT c s z_HTMLSanitizer.parse_comment)Nr )r )�__name__�
__module__�__qualname__r) r( r* rJ rL rE rF rM r/ r0 r1 r3 r2 r4 rN r r r7 r; r< r= r> r6 rT �
__classcell__r r )r r r "