
QKc           @   su   d  d l  Z  d  d l m Z m Z d  d l m Z d  d l m Z d e f d     YZ	 d e e	 f d     YZ
 d S(	   iN(   t   escapet   unescape(   t   HTMLTokenizer(   t
   tokenTypest   HTMLSanitizerMixinc           B   s  e  Z d  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. d/ d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d: d; d< d= d> d? d@ dA dB dC dD dE dF dG gG Z 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 g Z d 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 d d d g" 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 d d d d d d d d d d d d d7 d d d d d d d d d d d d d d gI 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 g- 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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(dw d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFd dGdHdId dJdKdLdMdNdOdPdQdRdSdTd dUdVdWdXdYdZd[d d\d d]d d^d d_d d d`dadbdcg Z d d d d d d d^g Z	 dddedfddgds ddddhd>g Z
 didc dd de df dfdjdgdq dkdz dldmd| d g Z dndodpdqdrdsdtdud d dfdvd dwdxd ddddd	d dydzd{d|d}d~dddddddddddddddddd g. Z dddddddddd dddddddddddddb ddd dddddddddddddg' Z dddd>dEdAdBdDg Z ddddddddddddddddddddddg Z e e e Z e e e Z e Z e Z e Z e Z d  Z d  Z RS(  sA    sanitization of XHTML+MathML+SVG and of inline style attributes.t   at   abbrt   acronymt   addresst   areat   bt   bigt
   blockquotet   brt   buttont   captiont   centert   citet   codet   colt   colgroupt   ddt   delt   dfnt   dirt   divt   dlt   dtt   emt   fieldsett   fontt   formt   h1t   h2t   h3t   h4t   h5t   h6t   hrt   it   imgt   inputt   inst   kbdt   labelt   legendt   lit   mapt   menut   olt   optgroupt   optiont   pt   pret   qt   st   sampt   selectt   smallt   spant   striket   strongt   subt   supt   tablet   tbodyt   tdt   textareat   tfoott   tht   theadt   trt   ttt   ut   ult   vart   mactiont   matht   merrort   mfract   mit   mmultiscriptst   mnt   mot   movert   mpaddedt   mphantomt   mprescriptst   mroott   mrowt   mspacet   msqrtt   mstylet   msubt   msubsupt   msupt   mtablet   mtdt   mtextt   mtrt   mundert
   munderovert   nonet   animatet   animateColort   animateMotiont   animateTransformt   circlet   defst   desct   ellipses	   font-faces   font-face-names   font-face-srct   gt   glypht   hkernt   linearGradientt   linet   markert   metadatas   missing-glypht   mpatht   patht   polygont   polylinet   radialGradientt   rectt   sett   stopt   svgt   switcht   textt   titlet   tspant   uset   accepts   accept-charsett	   accesskeyt   actiont   alignt   altt   axist   bordert   cellpaddingt   cellspacingt   chart   charofft   charsett   checkedt   classt   cleart   colst   colspant   colort   compactt   coordst   datetimet   disabledt   enctypet   fort   framet   headerst   heightt   hreft   hreflangt   hspacet   idt   ismapt   langt   longdesct	   maxlengtht   mediat   methodt   multiplet   namet   nohreft   noshadet   nowrapt   promptt   readonlyt   relt   revt   rowst   rowspant   rulest   scopet   selectedt   shapet   sizet   srct   startt   stylet   summaryt   tabindext   targett   typet   usemapt   valignt   valuet   vspacet   widths   xml:langt
   actiontypet   columnalignt   columnlinest   columnspacingt
   columnspant   deptht   displayt   displaystylet   equalcolumnst	   equalrowst   fencet	   fontstylet
   fontweightt   linethicknesst   lspacet   mathbackgroundt	   mathcolort   mathvariantt   maxsizet   minsizet   othert   rowalignt   rowlinest
   rowspacingt   rspacet   scriptlevelt	   selectiont	   separatort   stretchys
   xlink:hrefs
   xlink:shows
   xlink:typet   xmlnss   xmlns:xlinks   accent-heightt
   accumulatet   additivet
   alphabetics   arabic-formt   ascentt   attributeNamet   attributeTypet   baseProfilet   bboxt   begint   byt   calcModes
   cap-heights   color-renderingt   contentt   cxt   cyt   dt   dxt   dyt   descentt   durt   endt   fills   fill-opacitys	   fill-rules   font-familys	   font-sizes   font-stretchs
   font-styles   font-variants   font-weightt   fromt   fxt   fyt   g1t   g2s
   glyph-namet   gradientUnitst   hangings   horiz-adv-xs   horiz-origin-xt   ideographict   kt	   keyPointst
   keySplinest   keyTimess
   marker-ends
   marker-mids   marker-startt   markerHeightt   markerUnitst   markerWidtht   mathematicalt   maxt   mint   offsett   opacityt   orientt   origins   overline-positions   overline-thicknesss   panose-1t
   pathLengtht   pointst   preserveAspectRatiot   rt   refXt   refYt   repeatCountt	   repeatDurt   requiredExtensionst   requiredFeaturest   restartt   rotatet   rxt   ryt   slopet   stemht   stemvs
   stop-colors   stop-opacitys   strikethrough-positions   strikethrough-thicknesst   strokes   stroke-dasharrays   stroke-dashoffsets   stroke-linecaps   stroke-linejoins   stroke-miterlimits   stroke-opacitys   stroke-widtht   systemLanguages   text-anchort   tot	   transformt   u1t   u2s   underline-positions   underline-thicknesst   unicodes   unicode-ranges   units-per-emt   valuest   versiont   viewBoxt
   visibilityt   widthst   xs   x-heightt   x1t   x2s   xlink:actuates   xlink:arcroles
   xlink:roles   xlink:titles   xml:bases	   xml:spacet   yt   y1t   y2t
   zoomAndPans	   clip-paths   color-profilet   cursort   filtert   maskt   altGlypht   feImaget   patternt   textpatht   treft   azimuths   background-colors   border-bottom-colors   border-collapses   border-colors   border-left-colors   border-right-colors   border-top-colort	   directiont	   elevationt   floats   letter-spacings   line-heightt   overflowt   pauses   pause-afters   pause-beforet   pitchs   pitch-ranget   richnesst   speaks   speak-headers   speak-numerals   speak-punctuations   speech-ratet   stresss
   text-aligns   text-decorations   text-indents   unicode-bidis   vertical-aligns   voice-familyt   volumes   white-spacet   autot   aquat   blackt   blockt   bluet   boldt   botht   bottomt   brownt   collapset   dashedt   dottedt   fuchsiat   grayt   greens
   !importantt   italict   leftt   limet   maroont   mediumt   navyt   normalt   olivet   pointert   purplet   redt   rightt   solidt   silvert   tealt   topt   transparentt	   underlinet   whitet   yellowt   ed2kt   ftpt   httpt   httpst   irct   mailtot   newst   gophert   nntpt   telnett   webcalt   xmppt   calltot   feedt   urnt   aimt   rsynct   tagt   ssht   sftpt   rtspt   afsc   	      C   s  | d t  d t  d t  d f k r| d |  j k r| j d  r
t g  | d d  d  d  D]' \ } } | |  j k rb | | f ^ qb  } x |  j D] } | j |  s q n  t j d d	 t | |   j	   } | j
 d
 d	  } t j d |  r | j d  d |  j k r | | =q q WxC |  j D]8 } | | k r4t j d d t | |   | | <q4q4W| d |  j k rd | k rt j d | d  r| d =n  | j d  r|  j | d  | d <n  g  | j   D] \ } } | | g ^ q| d <n  | S| d t  d k r7d | d | d <ns | d rd	 j g  | d D]" \ } } d | t |  f ^ qR } d | d | f | d <n d | d | d <| d r| d d  d | d <n  t  d | d <| d =| Sn | d t  d k r n | Sd  S(   NR   t   StartTagt   EndTagt   EmptyTagR   t   datais   [` - -\s]+t    u   �s   ^[a-z0-9][-+.a-z0-9]*:t   :i    s   url\s*\(\s*[^#\s][^)]+?\)t    s
   xlink:hrefs   ^\s*[^#\s].*R   s   </%s>s    %s="%s"s   <%s%s>s   <%s>t   selfClosings   />t
   Characterst   Comment(   R   t   allowed_elementst   has_keyt   dictt   allowed_attributest   attr_val_is_urit   reR>   R   t   lowert   replacet   matcht   splitt   allowed_protocolst   svg_attr_val_allows_reft   svg_allow_local_hreft   searcht   sanitize_csst   itemst   joinR    (	   t   selft   tokenR   t   valt   attrst   attrt   val_unescapedR   t   v(    (    sQ   /home/sa3ruby/intertwingly.net/code/venus-bzr/planet/vendor/html5lib/sanitizer.pyt   sanitize_token   sX    !$	
2
<
c         C   sc  t  j d  j d |  } t  j d |  s1 d St  j d |  sG d Sg  } xt  j d |  D] \ } } | sx q` n  | j   |  j k r | j | d | d  q` | j d	  d
 j   d k r!x | j   D], } | |  j	 k r t  j d |  r Pq q W| j | d | d  q` | j   |  j
 k r` | j | d | d  q` q` Wd j |  S(   Ns   url\s*\(\s*[^\s)]+?\s*\)\s*R  s@   ^([:,;#%.\sa-zA-Z0-9!]|\w-\w|'[\s\w]+'|"[\s\w]+"|\([\d,\s]+\))*$R  s    ^\s*([-\w]+\s*:[^:;]*(;\s*|$))*$s   ([-\w]+)\s*:\s*([^:;]*)s   : t   ;t   -i    t
   backgroundR   t   margint   paddings\   ^(#[0-9a-f]+|rgb\(\d+%?,\d*%?,?\d*%?\)?|\d{0,2}\.?\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\))?)$(   s
   backgrounds   borders   margins   padding(   R  t   compileR>   R  t   findallR  t   allowed_css_propertiest   appendR  t   acceptable_css_keywordst   allowed_svg_propertiesR  (   R  R   t   cleant   propR   t   keyword(    (    sQ   /home/sa3ruby/intertwingly.net/code/venus-bzr/planet/vendor/html5lib/sanitizer.pyR     s*       	 (   t   __name__t
   __module__t   __doc__t   acceptable_elementst   mathml_elementst   svg_elementst   acceptable_attributest   mathml_attributest   svg_attributesR  R  R  t   acceptable_css_propertiesR  t   acceptable_svg_propertiest   acceptable_protocolsR  R  R  t   allowed_css_keywordsR  R  R  R  (    (    (    sQ   /home/sa3ruby/intertwingly.net/code/venus-bzr/planet/vendor/html5lib/sanitizer.pyR      s   								2t   HTMLSanitizerc           B   s)   e  Z d e e e e d   Z d   Z RS(   c         C   s#   t  j |  | | | | | |  d  S(   N(   R   t   __init__(   R  t   streamt   encodingt	   parseMetat
   useChardett   lowercaseElementNamet   lowercaseAttrName(    (    sQ   /home/sa3ruby/intertwingly.net/code/venus-bzr/planet/vendor/html5lib/sanitizer.pyR     s    c         c   s;   x4 t  j |   D]# } |  j |  } | r | Vq q Wd  S(   N(   R   t   __iter__R  (   R  R  (    (    sQ   /home/sa3ruby/intertwingly.net/code/venus-bzr/planet/vendor/html5lib/sanitizer.pyR     s    N(   R  R  t   Nonet   Truet   FalseR  R  (    (    (    sQ   /home/sa3ruby/intertwingly.net/code/venus-bzr/planet/vendor/html5lib/sanitizer.pyR     s   	(   R  t   xml.sax.saxutilsR    R   t	   tokenizerR   t	   constantsR   t   objectR   R  (    (    (    sQ   /home/sa3ruby/intertwingly.net/code/venus-bzr/planet/vendor/html5lib/sanitizer.pyt   <module>   s
   