7Re,@c@sddlmZmZmZddlZddlmZmZddlm Z ddl m Z Gddde Z Gd d d e e ZdS( i(uabsolute_importudivisionuunicode_literalsN(uescapeuunescapei(u HTMLTokenizer(u tokenTypescBsC|EeZdZdZdddddddd d d d d 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`dadbdcddgcZdedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dgZdddddddddddddddddddddddddddddddddddg#Zdddddddddddddddddddddddddddddddddddddddddddddddddddddd)ddddddddddddddddd8dddddddddddddddddddddddddddddddddddddd d d d d ddddRddddddddddddddddd d!d"d#d$d%d&d'gZd(dd)d)d)d*d+d,d-d.d/d0d1d2d3d4ddd5d6d7d8d9d9d:d;d<d=d=d=d>d?d d@dAdBdCdDd%d%dEdFdGdHdIg-ZdJdKdLdMdNdOdPdQdRdSdTdUdVdWddXddYdZd[d\d]d^d_d`d.daddbdcdddedfdgdhdidjdkdldmdndodpdqdrddsdtddudvdwdxdyddzd{d|d}d~dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd%ddddddddEddFddGdd'ddHdIddddgZ dddddddEdgZ dXdddbddd|d{dzddg Z dddddddddddddddgZ ddddddddddddd.ddd(dedfdhdidjddddddddddddddddddddddd"dd%g.Z ddddddddddddddddddddddddddddddddd d d d d ddg'ZdbdcdddddddgZdddddddddddddddddd d!d"d#d$gZeeeZeee Ze ZeZeZeZd%d&Zd'd(Zd)d*Zd+d,Zd-S(.uHTMLSanitizerMixinuA sanitization of XHTML+MathML+SVG and of inline style attributes.uauabbruacronymuaddressuareauarticleuasideuaudioububigu blockquoteubrubuttonucanvasucaptionucenteruciteucodeucolucolgroupucommandudatagridudatalistuddudeludetailsudfnudialogudirudivudludtuemu event-sourceufieldsetu figcaptionufigureufooterufontuformuheaderuh1uh2uh3uh4uh5uh6uhruiuimguinputuinsukeygenukbdulabelulegenduliumumapumenuumeterumulticolunavunextiduoluoutputuoptgroupuoptionupupreuprogressuqususampusectionuselectusmallusoundusourceuspaceruspanustrikeustrongusubusuputableutbodyutdutextareautimeutfootuthutheadutruttuuuuluvaruvideoumactionumathumerrorumfracumiu mmultiscriptsumnumoumoverumpaddedumphantomu mprescriptsumrootumrowumspaceumsqrtumstyleumsubumsubsupumsupumtableumtdumtextumtrumunderu munderoverunoneuanimateu animateColoru animateMotionuanimateTransformuclipPathucircleudefsudescuellipseu font-faceufont-face-nameu font-face-srcuguglyphuhkernulinearGradientulineumarkerumetadatau missing-glyphumpathupathupolygonupolylineuradialGradienturectusetustopusvguswitchutextutitleutspanuuseuacceptuaccept-charsetu accesskeyuactionualignualtu autocompleteu autofocusuaxisu backgroundubalanceubgcoloru bgpropertiesuborderu bordercolorubordercolordarkubordercolorlightu bottompaddingu cellpaddingu cellspacinguchu challengeucharucharoffuchoffucharsetucheckeduclassuclearucolorucolsucolspanucompactucontenteditableucontrolsucoordsudataudatafldu datapagesizeudatasrcudatetimeudefaultudelayudisabledu draggableudynsrcuenctypeuendufaceuforuframeu galleryimgugutteruheadersuheightu hidefocusuhiddenuhighuhrefuhreflanguhspaceuiconuidu inputmodeuismapukeytypeu leftspacingulangulistulongdesculoopu loopcountuloopendu loopstartulowulowsrcumaxu maxlengthumediaumethoduminumultipleunameunohrefunoshadeunowrapuopenuoptimumupatternupingu point-sizeuposterupqgupreloadupromptu radiogroupureadonlyurelu repeat-maxu repeat-minureplaceurequiredurevu rightspacingurowsurowspanurulesuscopeuselectedushapeusizeusrcustartustepustyleusummaryusuppressutabindexutargetutemplateu toppaddingutypeu unselectableuusemapuurnuvalignuvalueuvariableuvolumeuvspaceuvrmluwidthuwrapuxml:langu actiontypeu columnalignu columnlinesu columnspacingu columnspanudepthudisplayu displaystyleu equalcolumnsu equalrowsufenceu fontstyleu fontweightu linethicknessulspaceumathbackgroundu mathcoloru mathvariantumaxsizeuminsizeuotherurowalignurowlinesu rowspacingurspaceu scriptlevelu selectionu separatorustretchyu xlink:hrefu xlink:showu xlink:typeuxmlnsu xmlns:xlinku accent-heightu accumulateuadditiveu alphabeticu arabic-formuascentu attributeNameu attributeTypeu baseProfileubboxubeginubyucalcModeu cap-heightu clip-pathucolor-renderingucontentucxucyududxudyudescentudurufillu fill-opacityu fill-ruleu font-familyu font-sizeu font-stretchu font-styleu font-variantu font-weightufromufxufyug1ug2u glyph-nameu gradientUnitsuhangingu horiz-adv-xuhoriz-origin-xu ideographicuku keyPointsu keySplinesukeyTimesu marker-endu marker-midu marker-startu markerHeightu markerUnitsu markerWidthu mathematicaluoffsetuopacityuorientuoriginuoverline-positionuoverline-thicknessupanose-1u pathLengthupointsupreserveAspectRatioururefXurefYu repeatCountu repeatDururequiredExtensionsurequiredFeaturesurestarturotateurxuryuslopeustemhustemvu stop-coloru stop-opacityustrikethrough-positionustrikethrough-thicknessustrokeustroke-dasharrayustroke-dashoffsetustroke-linecapustroke-linejoinustroke-miterlimitustroke-opacityu stroke-widthusystemLanguageu text-anchorutou transformuu1uu2uunderline-positionuunderline-thicknessuunicodeu unicode-rangeu units-per-emuvaluesuversionuviewBoxu visibilityuwidthsuxux-heightux1ux2u xlink:actuateu xlink:arcroleu xlink:roleu xlink:titleuxml:baseu xml:spaceuyuy1uy2u zoomAndPanu color-profileucursorufilterumaskualtGlyphufeImageutextpathutrefuazimuthubackground-coloruborder-bottom-coloruborder-collapseu border-coloruborder-left-coloruborder-right-coloruborder-top-coloru directionu elevationufloatuletter-spacingu line-heightuoverflowupauseu pause-afteru pause-beforeupitchu pitch-rangeurichnessuspeaku speak-headeru speak-numeraluspeak-punctuationu speech-rateustressu text-alignutext-decorationu text-indentu unicode-bidiuvertical-alignu voice-familyu white-spaceuautouaquaublackublockublueuboldubothubottomubrownucollapseudashedudottedufuchsiaugrayugreenu !importantuitaliculeftulimeumaroonumediumunavyunormaluoliveupointerupurpleuredurightusolidusilverutealutopu transparentu underlineuwhiteuyellowued2kuftpuhttpuhttpsuircumailtounewsugopherunntputelnetuwebcaluxmppucalltoufeeduaimursyncutagusshusftpurtspuafscCs|d}|ttjkr/t|}n|tdtdtdfkr|d|jkrs|j||S|j||Sn|tdkrn|SdS(NutypeuStartTaguEndTaguEmptyTagunameuComment(ulistu tokenTypesukeysuallowed_elementsu allowed_tokenudisallowed_token(uselfutokenu token_type((u7/tmp/pip-zej_zi-build/pip/_vendor/html5lib/sanitizer.pyusanitize_tokens  u!HTMLSanitizerMixin.sanitize_tokencsd|krtfdd|ddddD}xjD]}||kr^qFntjddt||j}|jdd}tjd|rF|jd d j krF||=qFqFWxCj D]8}||krtjd d t||||s u4HTMLSanitizerMixin.allowed_token..iu [`- - \s]+uu�u^[a-z0-9][-+.a-z0-9]*:u:iuurl\s*\(\s*[^#\s][^)]+?\)u unameu xlink:hrefu ^\s*[^#\s].*ustylecSs"g|]\}}||gqS(((u.0unameuval((u7/tmp/pip-zej_zi-build/pip/_vendor/html5lib/sanitizer.pyu s i(udictuattr_val_is_uriureusubuunescapeulowerureplaceumatchusplituallowed_protocolsusvg_attr_val_allows_refusvg_allow_local_hrefusearchu sanitize_cssulistuitems(uselfutokenu token_typeuattrsuattru val_unescaped((uselfu7/tmp/pip-zej_zi-build/pip/_vendor/html5lib/sanitizer.pyu allowed_tokens4         &u HTMLSanitizerMixin.allowed_tokencCs|tdkr%d|d|dunameudataucSs,g|]"\}}d|t|fqS(u %s="%s"(uescape(u.0ukuv((u7/tmp/pip-zej_zi-build/pip/_vendor/html5lib/sanitizer.pyu s u7HTMLSanitizerMixin.disallowed_token..u<%s%s>u<%s>u selfClosingiu/>utypeu Charactersi(u tokenTypesujoinugetulistukeys(uselfutokenu token_typeuattrs((u7/tmp/pip-zej_zi-build/pip/_vendor/html5lib/sanitizer.pyudisallowed_tokens   u#HTMLSanitizerMixin.disallowed_tokencCsctjdjd|}tjd|s1dStjd|sGdSg}xtjd|D]\}}|sxq`n|j|jkr|j|d|dq`|jd d jdkr!x|jD],}||j krtjd| rPqqW|j|d|dq`|j|j kr`|j|d|dq`q`Wdj |S(Nuurl\s*\(\s*[^\s)]+?\s*\)\s*u u@^([:,;#%.\sa-zA-Z0-9!]|\w-\w|'[\s\w]+'|"[\s\w]+"|\([\d,\s]+\))*$uu ^\s*([-\w]+\s*:[^:;]*(;\s*|$))*$u([-\w]+)\s*:\s*([^:;]*)u: u;u-iu backgrounduborderumarginupaddingu\^(#[0-9a-f]+|rgb\(\d+%?,\d*%?,?\d*%?\)?|\d{0,2}\.?\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\))?)$(u backgrounduborderumarginupadding( ureucompileusubumatchufindalluloweruallowed_css_propertiesuappendusplituacceptable_css_keywordsuallowed_svg_propertiesujoin(uselfustyleucleanupropuvalueukeyword((u7/tmp/pip-zej_zi-build/pip/_vendor/html5lib/sanitizer.pyu sanitize_csss*  uHTMLSanitizerMixin.sanitize_cssN(u__name__u __module__u __qualname__u__doc__uacceptable_elementsumathml_elementsu svg_elementsuacceptable_attributesumathml_attributesusvg_attributesuattr_val_is_uriusvg_attr_val_allows_refusvg_allow_local_hrefuacceptable_css_propertiesuacceptable_css_keywordsuacceptable_svg_propertiesuacceptable_protocolsuallowed_elementsuallowed_attributesuallowed_css_propertiesuallowed_css_keywordsuallowed_svg_propertiesuallowed_protocolsusanitize_tokenu allowed_tokenudisallowed_tokenu sanitize_css(u __locals__((u7/tmp/pip-zej_zi-build/pip/_vendor/html5lib/sanitizer.pyuHTMLSanitizerMixin s                               uHTMLSanitizerMixincBs>|EeZdZddddddddZddZdS(u HTMLSanitizerc Cs)tj|||||||d|dS(Nuparser(u HTMLTokenizeru__init__(uselfustreamuencodingu parseMetau useChardetulowercaseElementNameulowercaseAttrNameuparser((u7/tmp/pip-zej_zi-build/pip/_vendor/html5lib/sanitizer.pyu__init__suHTMLSanitizer.__init__ccs;x4tj|D]#}|j|}|r|VqqWdS(N(u HTMLTokenizeru__iter__usanitize_token(uselfutoken((u7/tmp/pip-zej_zi-build/pip/_vendor/html5lib/sanitizer.pyu__iter__ suHTMLSanitizer.__iter__NTF(u__name__u __module__u __qualname__uNoneuTrueuFalseu__init__u__iter__(u __locals__((u7/tmp/pip-zej_zi-build/pip/_vendor/html5lib/sanitizer.pyu HTMLSanitizers u HTMLSanitizer(u __future__uabsolute_importudivisionuunicode_literalsureuxml.sax.saxutilsuescapeuunescapeu tokenizeru HTMLTokenizeru constantsu tokenTypesuobjectuHTMLSanitizerMixinu HTMLSanitizer(((u7/tmp/pip-zej_zi-build/pip/_vendor/html5lib/sanitizer.pyus