ó
Eü½cc           @   s¤   d  Z  d d l Z d d l m Z d d l m Z d d l m Z y e e f Wn e	 k
 ro d Z d Z n Xd Z
 d	 „  Z e d
 ƒ Z [ d „  Z d „  Z d S(   s3  Determine whether the message is approved for delivery.

This module only tests for definitive approvals.  IOW, this module only
determines whether the message is definitively approved or definitively
denied.  Situations that could hold a message for approval or confirmation are
not tested by this module.
iÿÿÿÿN(   t   typed_subpart_iterator(   t   mm_cfg(   t   Errorsi   i    s   
c         C   s   |  S(   N(    (   t   s(    (    s7   /export/web/mailman/mailman/Mailman/Handlers/Approve.pyt   _*   s    s®   Message rejected.
It appears that this message contains an HTML part with the
Approved: password line, but due to the way it is coded in the
HTML it can't be safely removed.
c         C   sÕ  g  } x0 d D]( } | j  | | ƒ } | | k	 r Pq q W| | k r5d  } t } x t | d d ƒ D] } Pqd W| d  k	 rd| j ƒ  d  k	 rd| j d t ƒ j ƒ  } d }	 x9 t t t	 | ƒ ƒ | ƒ D] \ }
 }	 |	 j
 ƒ  rÇ PqÇ qÇ W|	 j d	 ƒ } | d
 k rd|	 |  } |	 | d } | j ƒ  d k ra| j ƒ  } | |
 =t | t j | ƒ ƒ t } qaqdn  | r5| d t j | ƒ } x® t | d ƒ D]š } | d  k	 r‘| j ƒ  d  k	 r‘| j d t ƒ } t j | | ƒ røt | t j | d | ƒ ƒ q+t j | t j d d | ƒ ƒ r+t j t ‚ q+q‘q‘Wq5n  | | k	 r||  j t j t j t j f | ƒ r|d | d <d | d <n  g  | j d g  ƒ D] } | j
 ƒ  j ƒ  ^ q} |  j ƒ  j ƒ  | k rÑt j ‚ n  d  S(   Nt   approvedt   approves
   x-approveds	   x-approvet   textt   plaint   decodet    t   :i    i   s   :( |\s|&nbsp;)*s	   (?s)<.*?>t   adminapproveds   x-beenthere(   R   R   s
   x-approveds	   x-approve(   R   R   s	   x-approves
   x-approved(    t   gett   Nonet   FalseR    t   get_payloadt   Truet
   splitlinest   zipt   ranget   lent   stript   findt   lowert   lstript   reset_payloadt   NLt   joint   ret   escapet   searcht   subR   t   RejectMessaget   REJECTt   AuthenticateR   t   AuthListPostert   AuthListModeratort   AuthListAdmint   get_allt   GetListEmailt	   LoopError(   t   mlistt   msgt   msgdatat   missingt   hdrt   passwdt   partt   strippedt   linest   linet   linenot   it   namet   valuet   patternR   t
   beentheres(    (    s7   /export/web/mailman/mailman/Mailman/Handlers/Approve.pyt   process6   s\    (
	  	!		
1c         C   s   |  j  ƒ  p d } |  j ƒ  } |  j d ƒ } |  j d ƒ } |  d =|  d =|  j | | ƒ |  j | ƒ | r€ |  j d | ƒ n  | r™ |  j d | ƒ n  d  S(   Ns   us-asciit   formatt   delsps   content-transfer-encodings   content-typet   Formatt   DelSp(   t   get_content_charsett   get_content_typet	   get_paramt   set_payloadt   set_typet	   set_param(   R0   t   payloadt   csett   ctypeR;   R<   (    (    s7   /export/web/mailman/mailman/Mailman/Handlers/Approve.pyR   —   s    (   t   __doc__R   t   email.IteratorsR    t   MailmanR   R   R   R   t	   NameErrorR   R   R"   R:   R   (    (    (    s7   /export/web/mailman/mailman/Mailman/Handlers/Approve.pyt   <module>   s    
			a