
?]Mc           @   s  d  Z  d d k l Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k	 Z	 d d k
 Z
 d d k Z d d k Z d d k Z d d k Z d d k l Z d d k l Z d d k l Z l Z y d d k l Z Wn) e j
 o d Z e e i   Z n Xd d	 k l Z d d
 k l Z d d k l Z d d k l  Z  d d k! l" Z" y" d d k# Z# e# i$ Z% e# i& Z' Wn= e j
 o1 d d k$ Z$ d d k( Z( e$ i) Z% e( i) Z' n Xy e* e+ f Wn e, j
 o d Z* d Z+ n Xd Z- d Z. d Z/ d Z0 e e d Z1 e i2 d e i3  Z4 e i2 d e i3  Z5 d   Z6 d   Z7 d e* d  Z8 d   Z9 d   Z: d   Z; e i2 d  Z< e i2 d  Z= d    Z> e i2 d!  Z? d" d#  Z@ d e+ d$  ZB d%   ZC e+ d&  ZD d ZE d ZF g  ZG xA eE D]9 ZH x0 eF D]( ZI eG iJ eI eH  eG iJ eH eI  qWq	W[I [H d=   ZK d>   ZL e iM d?  ZN d@   ZO e* dA  ZP e* dB  ZQ e* dC  ZR e i2 dD e i3  ZS dE   ZT dF   ZU e+ dG  ZV dH   ZW dI eX f dJ     YZY d e+ d d dK  ZZ d e+ d d dL  Z[ h d dM 6d dN 6d dO 6d dP 6d dQ 6d dS 6d dT 6d dV 6d dW 6d dX 6d dY 6Z\ dZ   Z] d e* d[  Z^ d e+ d\  Z_ d]   Z` d^   Za d_   Zb d`   Zc da   Zd d d db  Ze d af dc   Zg d dd  Zh de   Zi df   Zj dg   Zk dh   Zl d di  Zm d dj  Zn dk   Zo dl   Zp dm dn do dp dq dr ds dt du dv dw dx dy dz 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 d d d d d d d d ga Zq e i2 d ir eq  e i3  Zs e i2 d  Zt e i2 d e i3  Zu d   Zv d   Zw d S(   s   Miscellaneous essential routines.

This includes actual message transmission routines, address checking and
message and address munging, a handy-dandy routine to map a function on all
the mailing lists, and whatever else doesn't belong elsewhere.

i(   t   nested_scopesN(   t   HeaderParseError(   t   UnicodeType(   t
   whitespacet   digits(   t   ascii_letterst   abcdefghijklmnopqrstuvwxyz(   t   mm_cfg(   t   Errors(   t   Site(   t   SafeDict(   t   syslogi   i    t    u    s   
t   .t   _s   %\(([_a-z]\w*?)\)s?s%   (\${2})|\$([_a-z]\w*)|\${([_a-z]\w*)}c         C   sU   t  i |   } x? d D]7 } t i i | d |  } t i i |  o t Sq Wt S(   s'   Return true iff list `listname' exists.s   .pcks	   .pck.lasts   .dbs   .db.lastt   config(   s   .pcks	   .pck.lasts   .dbs   .db.last(   R	   t   get_listpatht   ost   patht   joint   existst   Truet   False(   t   listnamet   basepatht   extt   dbfile(    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   list_existsX   s     	c           C   s
   t  i   S(   s8   Return the names of all lists in default list directory.(   R	   t   get_listnames(    (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt
   list_namesg   s    iF   c         C   s  d } t  i d |   } xt| D]l} g  } t } x | i t  D] } | p | i |  qA n | o | d t j o
 t }	 n t }	 | o' |	 o  | d i   d | | d <n | i |  |	 } qA Wx| D]}  x|  ot |   | j o |  } d }  n\| }
 x- |
 d j o |  |
 t j o |
 d 8}
 qW|
 } x- | d j o |  | t j o | d 8} qHW| d j o | } x3 | t |   j  o |  | t j o | d 7} qW| }
 x3 |
 t |   j  o |  |
 t j o |
 d 7}
 qW|
 d 8}
 n |  | d  d } |
 d 7}
 x3 |
 t |   j  o |  |
 t j o |
 d 7}
 q'W|  |
 }  | | 7} q W| d 7} q W| d 7} q W| d  S(	   s  Wrap and fill the text to the specified column.

    Wrapping is always in effect, although if it is not possible to wrap a
    line (because some word is longer than `column' characters) the line is
    broken at the next available whitespace boundary.  Paragraphs are also
    always filled, unless honor_leading_ws is true and the line begins with
    whitespace.  This is the algorithm that the Python FAQ wizard uses, and
    seems like a good compromise.

    R   s   

i    it    i   s   
i(	   t   ret   splitR   t   NLt   appendR   R   t   rstript   len(   t   textt   columnt   honor_leading_wst   wrappedt   parast   parat   linest   fillprevt   linet   fillthist   bolt   eol(    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   wrapo   sj      
 
  
   $ $
 $
c         C   s"   d } d } | i  |  i |   S(   Ns   
 .
s   
.
(   R   R    (   R%   t   JOINERt   SEP(    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   QuotePeriods   s    c         C   sp   d  } d  } |  i   }  |  i d  } | d j  o |  d  f S|  |  } |  | d } | i d  } | | f S(   Nt   @i   R   (   t   Nonet   lowert   findR    (   t   emailt   usert   domaint   at_signt   rest(    (    s!   /usr/lib/mailman/Mailman/Utils.pyt
   ParseEmail   s    
c         C   s?   |  i  d  } | d j o |  S|  |  d |  | d i   S(   s3   returns the address with the domain part lowercasedR5   ii   (   R8   R7   (   t   addrt   atind(    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   LCDomain   s    s   [][()<>|;^,\000-\037\177-\377]s   [:\\"]c         C   s   |  p |  i  d  d j o t i  n t i |   p |  d d j o t i |   n t |   \ } } | p t i |   n t |  d j  o t i |   n | i d  o | i	 d  p$ t
 i |  o t i |   q n d S(   s0   Verify that an email address isn't grossly evil.R   i    t   -i   t   "N(   t   countR   t   MMBadEmailErrort	   _badcharst   searcht   MMHostileAddressR>   R$   t
   startswitht   endswitht	   _specials(   t   sR:   t   domain_parts(    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   ValidateEmail   s    ! s   [^\x21-\x7e]t	   PATH_INFOc         C   s   t  i i |   } | oh t i |  o$ t i |  d } t d d  n g  } | i d  D] } | o | | qa qa ~ Sd  S(   Ni    t   errors(   Warning: Possible malformed path attack.t   /(   R   t   environt   gett   CRNLpatRG   R    R   R6   (   t   envarR   t   _[1]t   p(    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   GetPathPieces   s    4c         C   s1  | d j o3 t i t   } | d d j o | d } q@ n t i i d  } | d j o, t i i d d  t i i d d  } n t i |  d } | ov | i |  of | t	 |  } | i
 d  } | d	 j o | i d d	 |  } n | i d  } d
 | |  } n | |  } | t i S(   s   target - scriptname only, nothing extra
    web_page_url - the list's configvar of the same name
    absolute - a flag which if set, generates an absolute url
    iRQ   t   REQUEST_URIt   SCRIPT_NAMER   RO   i   t   ?i    s   ../N(   R6   R   t   DEFAULT_URL_PATTERNt
   get_domainR   RR   RS   t   urlparseRI   R$   R8   RD   t   CGIEXT(   t   targett   web_page_urlt   absolutet   fullpatht   baseurlt   iRD   R   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt	   ScriptURL   s$    
c         C   s   |  i    }  t |   \ } } |  g } | oS | d } xF t |  d j o. | i d | t i |  f  | d } q; Wn | S(   s  returns a sorted list of addresses that could possibly match
    a given name.

    For Example, given scott@pobox.com, return ['scott@pobox.com'],
    given scott@blackbox.pobox.com return ['scott@blackbox.pobox.com',
                                           'scott@pobox.com']i   i   s   %s@%s(   R7   R>   R$   R"   t   DOTR   (   t   nameR:   R;   t   res(    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   GetPossibleMatchingAddrs  s    	
  c         C   sQ   h  } | o% x= |  D] } t  | | i   <q Wn x |  D] } t  | | <q9 W| S(   s<   Return a dict keyed by the entries in the list passed to it.(   R   R7   (   t   Lt   foldcaset   dRe   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt	   List2Dict0  s      t   at   eRe   t   ot   ut   bt   cRm   t   ft   gt   ht   kt   mt   nRW   t   rRL   t   tt   vt   wt   xt   zc         C   sL   g  } x2 t  |  d |  j  o | i t i t   q	 Wt i |  |   S(   Ni   (   R$   R"   t   randomt   choicet
   _syllablest   EMPTYSTRINGR   (   t   lengtht   syls(    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   UserFriendly_MakeRandomPasswordH  s
     c      
   C   sS  d } g  } d  } zx | |  j  o y t i |  |  } Wn t t f j
 o | d  j oc y t i d t i  } Wq t j
 o7 } | i t i	 j o   n t
 d d  t |   SXn t i | |  |  } n X| i |  | t |  7} q Wt i t i |   } | i d d  |   SWd  | d  j	 o t i |  n Xd  S(   Ni    s   /dev/urandomRP   s+   urandom not available, passwords not secures   
R   (   R6   R   t   urandomt   AttributeErrort   NotImplementedErrort   opent   O_RDONLYt   OSErrort   errnot   ENOENTR   R   t   readR"   R$   t   base64t   encodestringR   R   t   replacet   close(   R   t	   bytesreadt   bytest   fdt   newbytesRp   RL   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   Secure_MakeRandomPasswordO  s2     c         C   s   t  i o t |   St |   S(   N(   R   t   USER_FRIENDLY_PASSWORDSR   R   (   R   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   MakeRandomPasswordp  s    
c          C   sR   t  t i   d  }  t  t i   d  } d   } d t t | |  | f   S(   Ni4   c         S   s\   d |  j o
 d j  n o |  d 7}  n d |  j o
 d j  n o |  d 7}  n |  S(   Ni    i   iA   i4   iG   (    (   Rt   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   mklettery  s
    s   %c%c(   t   intR   t   tuplet   map(   t   chr1t   chr2R   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   GetRandomSeedv  s    	c         C   s{   | o t  i } n
 t  i } t i d  } z: t | d  } | i t |   i   d  | i	   Wd  t i |  Xd  S(   Ni   R~   s   
(
   R   t   SITE_PW_FILEt   LISTCREATOR_PW_FILER   t   umaskR   t   writet   sha_newt	   hexdigestR   (   t   pwt	   siteadmint   filenamet   omaskt   fp(    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   set_global_password  s    	c         C   s~   |  o t  i } n
 t  i } y* t |  } | i   d  } | i   Wn0 t j
 o$ } | i t i j o   n d  SX| S(   Ni(
   R   R   R   R   R   R   t   IOErrorR   R   R6   (   R   R   R   t	   challengeRp   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   get_global_password  s    	 c         C   s4   t  |  } | d  j o d  S| t |   i   j S(   N(   R   R6   R   R   (   t   responseR   R   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   check_global_password  s    s   &amp;((?:#[0-9]+|[a-z]+);)c         C   s   t  i d t i |  d t  S(   Ns   &\1t   quote(   t   _ampret   subt   cgit   escapeR   (   RL   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   websafe  s    c         C   se   |  i  d d  } t |  d j o6 y | d t | d  f SWq[ t j
 o q[ Xn |  d f S(   Nt   :i   i   i    iw   (   R    R$   R   t
   ValueError(   RL   t   parts(    (    s!   /usr/lib/mailman/Mailman/Utils.pyt	   nntpsplit  s    	c         C   s,   | o |  i  d d  S|  i  d d  Sd S(   s   Make email address unrecognizable to web spiders, but invertable.

    When for_text option is set (not default), make a sentence fragment
    instead of a token.R5   s    at s   --at--N(   R   (   R?   t   for_text(    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   ObscureEmail  s    c         C   s   |  i  d d  S(   s!   Invert ObscureEmail() conversion.s   --at--R5   (   R   (   R?   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   UnobscureEmail  s    t	   OuterExitc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s!   /usr/lib/mailman/Mailman/Utils.pyR     s   c         C   s  g  } | d  j	 o | i |  n | d  j	 o | i | i  n | i t i  g  } | d  j	 o9 | i | i    | i t i i t i	 | i
   n | i t i i t i	 d   | i t i	  d  } y x | D]} } xt | D]l } t i i | | |   }	 y t |	  } t  Wq t j
 o) }
 |
 i t i j o   n d  } q Xq Wq WWn t j
 o n X| d  j ov y+ t i i t i	 d |   }	 t |	  } Wqt j
 o8 }
 |
 i t i j o   n t t i d |    qXn | i   } | i   | } | d  j	 o y` t |  } y | i |  } Wn: t j
 o. t | t |  d  } | i |  } n XWqt t f j
 o }
 t d d |	 |
  qXn | o | |	 f St |  |	 f S(   Nt   sitet   ens   No template file foundR   RP   s   broken template: %s
%s(   R6   R"   t   preferred_languageR   t   DEFAULT_SERVER_LANGUAGERc   R   R   R   t   TEMPLATE_DIRt	   host_nameR   R   R   R   R   R   R   R
   t   interpolatet   UnicodeErrort   unicodet
   GetCharSett	   TypeErrorR   R   R1   (   t   templatefilet   dictt   rawt   langt   mlistt	   languagest
   searchdirsR   t   dirR   Rp   t   templateR%   t   sdictt	   utemplate(    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   findtext  sj    4&  
  
	c         C   s   t  |  | | | |  d S(   Ni    (   R   (   R   R   R   R   R   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   maketextC  s    t   confirmt   helpt   infot   listst   optionsi   t   passwordt   removei   t   sett	   subscribet   unsubscribet   whoc      
   C   s  d } g  } xi t  i i |   D]U } | d j o Pn | i   o | d 7} n | t i j o t S| i |  q Wt i	 |  } t
 i | i   i    o t S| d  } t |  i d d   } | i |  x | D] } | i   p q n g  } | i   D] } | | i   q	~ }	 t
 i |	 d d  \ }
 } |
 d  j o | d  j o q n |
 t |	 d  j o
 | j n o. |	 d d j o |	 d d j o q n t Sq Wt S(   Ni    s   -- i   i   t   subjectR   R   i   t   ont   off(   NN(   R   R   (   R9   t	   Iteratorst   body_line_iteratort   stripR   t   DEFAULT_MAIL_COMMANDS_MAX_LINESR   R"   R!   R   t	   ADMINDATAt   has_keyR7   R   t   strRS   R    R6   R$   (   t   msgt   linecntR+   R-   t   bodytextt	   bodylinesR   RV   t   wordt   wordst   minargst   maxargs(    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   is_administriviaZ  s<     
 -("	c         C   s   |  } t  i i d  o t  i d } nC t  i i d  o/ t  i i d  o t  i d t  i d } n | o t |  S| S(   s  Return the full virtual path this CGI script was invoked with.

    Newer web servers seems to supply this info in the REQUEST_URI
    environment variable -- which isn't part of the CGI/1.1 spec.
    Thus, if REQUEST_URI isn't available, we concatenate SCRIPT_NAME
    and PATH_INFO, both of which are part of CGI/1.1.

    Optional argument `fallback' (default `None') is returned if both of
    the above methods fail.

    The url will be cgi escaped to prevent cross-site scripting attacks,
    unless `escape' is set to 0.
    RY   RZ   RO   (   R   RR   R   R   (   t   fallbackR   t   url(    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   GetRequestURI  s    &c         C   s   x |  o | o |   n y t  i d t  i  \ } } Wn: t j
 o. } | i t i j o   n |  i   Pn X| d j o% y |  | =Wq t j
 o q Xn | o Pq q Wd  S(   Nii    (   R   t   waitpidt   WNOHANGR   R   t   ECHILDt   cleart   KeyError(   t   kidst   funct   oncet   pidt   statusRp   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   reap  s$     
	c         C   s   t  i |  d S(   Ni    (   R   t   LC_DESCRIPTIONS(   R   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   GetLanguageDescr  s    c         C   s   t  i |  d S(   Ni   (   R   R  (   R   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyR     s    c         C   s   t  i |  d S(   Ni   (   R   R  (   R   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   GetDirection  s    c         C   s   t  i i |   S(   N(   R   R  R   (   R   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt
   IsLanguage  s    c          C   s   t  i i d t  i i d   }  t  i i d  } | o- |  i d |  o |  t |  d  }  n t i o |  o |  i   St i o t	 i	 t i  d p t i
 } | i   Sd  S(   Nt	   HTTP_HOSTt   SERVER_NAMEt   SERVER_PORTR   i   (   R   RR   RS   RJ   R$   R   t   VIRTUAL_HOST_OVERVIEWR7   t   DEFAULT_URLR^   t   DEFAULT_URL_HOST(   t   hostt   portt   hostname(    (    s!   /usr/lib/mailman/Mailman/Utils.pyR]     s    !
	c         C   s_   |  d  j o t i i t   t    }  n | d  j o d t i |  f Sd t i | |  f S(   Ns   %s@%ss   %s-%s@%s(   R6   R   t   VIRTUAL_HOSTSRS   R]   t   MAILMAN_SITE_LIST(   R  t   extra(    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   get_site_email  s
    c         C   s<   d t  t i   t i   |  i   |  i f } t  d 7a  | S(   Ns   <mailman.%d.%d.%d.%s@%s>i   (   t   _serialt   timeR   t   getpidt   internal_nameR   (   R   t   msgid(    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   unique_message_id  s
    
c         C   s6   |  d  j o t i   d  }  n t i |  d d  S(   Ni   i    i   i(   i    (   i    i    i    i    i    (   i(   R6   R  t	   localtimet   mktime(   t   date(    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   midnight  s    c         C   s   |  i  d d  i  d d  }  t i |   } xt t d t |  d  D]Z } | | d o3 | | d d t j o d | | d	 | | <qF d | | | | <qF Wt i |  S(
   s$   Convert from %-strings to $-strings.t   $s   $$s   %%t   %i   i   i    s   ${t   }(   R   t   creR    t   rangeR$   t
   IDENTCHARSR   R   (   RL   R   Re   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt	   to_dollar  s     (c         C   s   |  i  d d  i  d d  }  t i |   } x t d t |  d  D]z } | | d
 j	 o d | | <qF | | d d
 j	 o" d | | d d | | d <qF d | | d	 d | | d	 <qF Wt i t d
 |   S(   s$   Convert from $-strings to %-strings.R$  s   %%s   $$R#  i   i   s   %(s   )si   N(	   R   t   dreR    R'  R$   R6   R   R   t   filter(   RL   R   Re   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt
   to_percent  s     ""c         C   si   h  } x\ t  d g  } t i |   D]$ \ } } } | | p | p d q# ~  D] } t | | <qQ W| S(   s?   Return the set (dictionary) of identifiers found in a $-string.N(   R+  R6   R*  t   findallR   (   RL   Rm   RV   Ro   Rs   Rt   Rh   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   dollar_identifiers  s
    K c         C   s.   h  } x! t  i |   D] } t | | <q W| S(   s?   Return the set (dictionary) of identifiers found in a %-string.(   R&  R-  R   (   RL   Rm   Rh   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   percent_identifiers  s
     c      	      sO  g   t  i d |   }  f d   }   f d   } xt o  i | | i d    | p Pn | i d  } | i d  oM y | t | d   Wq7t j
 o"  i | d | d   q7Xq9 t i	 i
 | d	  } | i d  o+ | i d  o | t | d d
 !  q9  i | |   q9 Wt i   } | S(   Ns   &(?P<ref>[^;]+);c            s     i  t |    d  S(   N(   R"   t   unichr(   Re   (   t   newparts(    s!   /usr/lib/mailman/Mailman/Utils.pyt   appchr,  s    c            s_   t  |  t  o |  S  d  j o
 d } n$ t    } | d j o
 d } n t |  | d  S(   Ns
   iso-8859-1s   us-asciiR   (   t
   isinstanceR   R6   R   (   RL   t   charset(   R   (    s!   /usr/lib/mailman/Mailman/Utils.pyt	   tounicode/  s    

i    t   #i   t   &t   ;R[   i(   R   R    R   R"   t   popRI   R   R   t   htmlentitydefst
   entitydefsRS   RJ   R   R   (   RL   R   R   R2  R5  t   refRt   t   newstr(    (   R   R1  s!   /usr/lib/mailman/Mailman/Utils.pyt   canonstr)  s*     $ c         C   s   |  d  j o
 d }  n | d  j o
 d } n t |  } y5 t |  t  o |  i |  St |  |  } |  SWn t j
 o t |   SXd  S(   Nu    s   us-ascii(   R6   R   R3  R   t   encodeR   R   t   uquote(   RL   R   R4  Rr   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt
   uncanonstrX  s    

c         C   se   g  } xI |  D]A } t  |  } | d j o | i d |  q | i |  q Wt t i |   S(   Ni   s   &#%3d;(   t   ordR"   R   R   R   (   RL   Ro   Rt   Rq   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyR@  m  s     c         C   s   yS t  i i t  i i |    } | i   } t i | i    } | i | d  SWn/ t	 t
 t t f j
 o t i |  i    SXd  S(   NR   (   R9   t   Headert   make_headert   decode_headert   __unicode__t   UEMPTYSTRINGR   t
   splitlinesR?  t   LookupErrorR   R   R   R   (   RL   t   csetRw   t   ustrR-   (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   oneliney  s    s   <i?frames2   <link(?! rel="SHORTCUT ICON" href="<mm-favicon>">)s   <metas   <objects   <scripts   \bj(?:ava)?script\bs   \bvbs(?:cript)?\bs   \bdomactivate\bs   \bdomattrmodified\bs   \bdomcharacterdatamodified\bs   \bdomfocus(?:in|out)\bs   \bdommenuitem(?:in)?active\bs   \bdommousescroll\bs$   \bdomnodeinserted(?:intodocument)?\bs#   \bdomnoderemoved(?:fromdocument)?\bs   \bdomsubtreemodified\bs   \bfscommand\bs   \bonabort\bs   \bon(?:de)?activate\bs   \bon(?:after|before)print\bs   \bon(?:after|before)update\bs8   \bonbefore(?:(?:de)?activate|copy|cut|editfocus|paste)\bs   \bonbeforeunload\bs   \bonbegin\bs
   \bonblur\bs   \bonbounce\bs   \bonbroadcast\bs   \bon(?:cell)?change\bs   \boncheckboxstatechange\bs   \bon(?:dbl)?click\bs   \bonclose\bs   \boncommand(?:update)?\bs   \boncomposition(?:end|start)\bs   \boncontextmenu\bs   \boncontrolselect\bs
   \boncopy\bs	   \boncut\bs   \bondataavailable\bs!   \bondataset(?:changed|complete)\bs5   \bondrag(?:drop|end|enter|exit|gesture|leave|over)?\bs   \bondragstart\bs
   \bondrop\bs	   \bonend\bs   \bonerror(?:update)?\bs   \bonfilterchange\bs   \bonfinish\bs   \bonfocus(?:in|out)?\bs
   \bonhelp\bs   \boninput\bs   \bonkey(?:up|down|press)\bs   \bonlayoutcomplete\bs   \bon(?:un)?load\bs   \bonlosecapture\bs   \bonmedia(?:complete|error)\bs6   \bonmouse(?:down|enter|leave|move|out|over|up|wheel)\bs   \bonmove(?:end|start)?\bs   \bon(?:off|on)line\bs   \bonoutofsync\bs   \bonoverflow(?:changed)?\bs   \bonpage(?:hide|show)\bs   \bonpaint\bs   \bonpaste\bs   \bonpause\bs*   \bonpopup(?:hidden|hiding|showing|shown)\bs   \bonprogress\bs   \bonpropertychange\bs   \bonradiostatechange\bs   \bonreadystatechange\bs   \bonrepeat\bs   \bonreset\bs   \bonresize(?:end|start)?\bs   \bonresume\bs   \bonreverse\bs'   \bonrow(?:delete|enter|exit|inserted)\bs#   \bonrows(?:delete|enter|inserted)\bs   \bonscroll\bs
   \bonseek\bs   \bonselect(?:start)?\bs   \bonselectionchange\bs   \bonstart\bs
   \bonstop\bs   \bonsubmit\bs   \bonsync(?:from|to)preference\bs   \bonsyncrestored\bs
   \bontext\bs   \bontimeerror\bs   \bontrackchange\bs   \bonunderflow\bs   \bonurlflip\bs   \bseeksegmenttime\bs   \bsvgabort\bs   \bsvgerror\bs   \bsvgload\bs   \bsvgresize\bs   \bsvgscroll\bs   \bsvgunload\bs   \bsvgzoom\bt   |s   [ -	--]s,   (&#[0-9]+;?)|(&#x[0-9a-f]+;?)|(%[0-9a-f]{2})c         C   s   |  i    i   i d  } yJ | i d  p | i d  o t | d d  } n t | d  } Wn t j
 o d SX| d j  o t |  Sd Sd	 S(
   s=   Translate &#... and %xx encodings into the encoded character.s   &#;R   R$  i   i   i
   R   i   N(   t   groupR7   R   RI   R   R   t   chr(   t   mot   matcht   val(    (    s!   /usr/lib/mailman/Mailman/Utils.pyt
   _translate  s     c         C   s5   t  i t i d t i t |     o t St Sd S(   sW  Check HTML string for various tags, script language names and
    'onxxx' actions that can be used in XSS attacks.
    Currently, this a very simple minded test.  It just looks for
    patterns without analyzing context.  Thus, it potentially flags lots
    of benign stuff.
    Returns True if anything suspicious found, False otherwise.
    R   N(   t   _badhtmlRG   t   _filtercharsR   t   _encodedcharsRS  R   R   (   t   html(    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   suspiciousHTML  s    	(   Ro   Rp   Re   Rq   Rr   (   Rs   Rt   Rm   Ru   Rv   Rw   Rx   Ry   Rz   RW   R{   RL   R|   R}   R~   R   R   (   i   i   (   i    i    (   i    i    (   i    i    (   i    i    (   i   i   (   i    i    (   i   i   (   i    i   (   i    i   (   i    i   (x   t   __doc__t
   __future__R    R   t   sysR   R   R  R   R   R   R^   R:  t   email.HeaderR9   t   email.Iteratorst   email.ErrorsR   t   typesR   t   stringR   R   R   t   ImportErrort   _lowert   uppert   MailmanR   R   R	   t   Mailman.SafeDictR
   t   Mailman.Logging.SyslogR   t   hashlibt   md5t   md5_newt   sha1R   t   shat   newR   R   t	   NameErrorR   RG  R!   Rg   R(  t   compilet
   IGNORECASER&  R*  R   R   R1   R4   R>   RA   RF   RK   RN   RT   RX   R6   Rf   Rj   Rn   t   _vowelst   _consonantsR   R}   Rt   R"   R   R   t   MEMBER_PASSWORD_LENGTHR   R   R   R   R   R   R   R   R   R   t	   ExceptionR   R   R   R   R   R   R  R	  R   R
  R  R]   R  R  R  R"  R)  R,  R.  R/  R>  RA  R@  RL  t	   _badwordsR   RT  RU  RV  RS  RX  (    (    (    s!   /usr/lib/mailman/Mailman/Utils.pyt   <module>   s  				K						   		!			
	o
	'										/					
