‰PNG  IHDR @ @ ªiqÞ pHYs   šœ —tEXtComment  Dfc @sdZdZdZdZddlZddlZejdeddd d d gZej d ej Z ej d ej Z ej dej ej BZej dej ej BZej dZej dej Zej dej Zej dej Zdd0dYZdd1dYZdZdZddZddZej dZej dZdZej d Zd!Zej d"ej Zej d#ej Z ej d$Z!d%Z"d&Z#ddl$Z$e%d'kse&e$j'dkre$j'ddkrddl(Z(d(Z)dZ*e(j(e$j'd)d*\Z+Z,e&e,d2kr}e)GHe$j-d)nd3e+kd4e+kksd5e+krd6e+kre)GHe$j-d)nxe+D]\Z.Z/e.d+kre#Z0qe.d-kreZ0qe.d/krJye1e/ZWq_e2e3fk rFe)GHe$j-d)q_Xqe.d.krd)Z*qqWe&e,dkre$j4e$j5fZ6n<e&e,d)kre,de$j5fZ6ne,de,d)fZ6e*re6e*fZ6ne0e6ndS(7sMimification and unmimification of mail messages. Decode quoted-printable parts of a mail message or encode using quoted-printable. Usage: mimify(input, output) unmimify(input, output, decode_base64 = 0) to encode and decode respectively. Input and output may be the name of a file or an open file object. Only a readline() method is used on the input file, only a write() method is used on the output file. When using file names, the input and output file names may be the same. Interactive usage: mimify.py -e [infile [outfile]] mimify.py -d [infile [outfile]] to encode and decode respectively. Infile defaults to standard input and outfile to standard output. is ISO-8859-1s> iNs>the mimify module is deprecated; use the email package insteaditmimifytunmimifytmime_encode_headertmime_decode_headers.^content-transfer-encoding:\s*quoted-printables$^content-transfer-encoding:\s*base64s0^content-type:.*multipart/.*boundary="?([^;" ]*)s:^(content-type:.*charset=")(us-ascii|iso-8859-[0-9]+)(".*)s^-* s=([0-9a-f][0-9a-f])s=\?iso-8859-1\?q\?([^? ]+)\?=s^subject:\s+re: tFilecBs eZdZdZdZRS(s{A simple fake file object that knows about limited read-ahead and boundaries. The only supported method is readline().cCs||_||_d|_dS(N(tfiletboundarytNonetpeek(tselfRR((s/usr/lib64/python2.7/mimify.pyt__init__3s  cCs||jdk rdS|jj}|s,|S|jrx||jdkrU||_dS||jdkrx||_dSn|S(Nts s-- (RRRtreadlineR(R tline((s/usr/lib64/python2.7/mimify.pyR 8s   (t__name__t __module__t__doc__R R (((s/usr/lib64/python2.7/mimify.pyR/s t HeaderFilecBseZdZdZRS(cCs||_d|_dS(N(RRR(R R((s/usr/lib64/python2.7/mimify.pyR Hs cCs|jdk r$|j}d|_n|jj}|s=|Stj|rP|Sxj|jj|_t|jdks|jddkr|jddkr|S||j}d|_qSdS(Nit s (RRRR thetmatchtlen(R R ((s/usr/lib64/python2.7/mimify.pyR Ls  & (RRR R (((s/usr/lib64/python2.7/mimify.pyRGs cCsd}d}xjtj||}|dkr1Pn||||jd!tt|jdd}|jd}q|||S(s6Decode a single line of quoted-printable text to 8bit.R iiiN(t mime_codetsearchRtstarttchrtinttgrouptend(R tnewlinetpostres((s/usr/lib64/python2.7/mimify.pyt mime_decode^s cCsd}d}xtj||}|dkr1Pn|jd}dj|jd}||||jd!t|}|jd}q|||S(sDecode a header line to 8bit.R iiRt_N( t mime_headRRRtjointsplitRR R(R RRRR((s/usr/lib64/python2.7/mimify.pyRks $ic CsEd}d}d}d}|jr=|jd tkr=t}nd}t|}x |j} | shdS|r| t| |kr| t|} |} nd} t| } tj| rd}qRn|rt j| rd}qRn|j | | | rt j| rd}nt j| } | rFd| j d}ntj| rRPqRqR|rw|sn|rwd}nx|j} | sdStjtd| } |r| t| |kr| t|} |} nd} x|rw| |dkr|j | | d}d} Pn| |d krs|j | | t||} t| ||| j} | sPqqnPqW| r|rx]| d d kr| d } |j} | tt tkr| tt} n| | } qWt| } n| r$|r$| r$d dl}|j| } n| rz|j | | qzqzdS( s?Convert a quoted-printable part of a MIME mail message to 8bit.iiR Nis--s\1s-- s is= i(RRtQUOTERR RRtqpRt base64_retwritetrepltmpRRtretsubR"Rt unmimify_partRR tbase64t decodestring(tifiletofilet decode_base64t multiparttquoted_printablet is_base64tis_repltprefixthfileR tpreftmp_restnifileRR.((s/usr/lib64/python2.7/mimify.pyR-zs               c Cst|tdkrt|}t|tdkr||krddl}|jj|\}}|j||jj|d|qn|}t|tdkrt|d}n|}t|d}t ||||j dS(s>Convert quoted-printable parts of a MIME mail message to 8bit.R iNt,tw( ttypetopentostpathR$trenameR#RRR-tflush( tinfiletoutfileR2R0R@tdtfR1R;((s/usr/lib64/python2.7/mimify.pyRs $ )s[=-]s[=?-]cCsf|rt}nt}d}d}t|dkrb|d dkrbdtdj}d}nxk|j||}|d krPn||||jd!dt|jdj}|j d}qe|||}d}xwt|dkr]d }x2||d ks&||dd kr3|d}qW|d}||| d }||}qW||S( sZCode a single line as quoted-printable. If header is set, quote some extra characters.R iisFrom s=%02xtFiiKiIt=s= N( tmime_header_chart mime_charRtordtupperRRRRR(R theadertregRRRti((s/usr/lib64/python2.7/mimify.pyt mime_encodes2 "   ' s<([ (]|^)([-a-zA-Z0-9_+]*[-][-a-zA-Z0-9_+-]*)(?=[ )]| )cCsd}d}xxtj||}|dkr1Pnd||||jd!|jdtt|jddf}|jd}q|||S(s.Code a single header line as quoted-printable.R is%s%s%s=?%s?Q?%s?=iiN(t mime_headerRRRRtCHARSETRQR(R RRR((s/usr/lib64/python2.7/mimify.pyRs "s^mime-version:s^content-transfer-encoding:s[-]cCs/d}}}d}d}}} g} d} g} d} t|}x|j}|s_Pn| r~tj|r~d}ntj|rd}ntj|rd}tj|rd}qt j|rd}qnt j|}|r d|j d}nt j|r"|} Pn| j |qIx:|j}|sKPn|r||dkrk|} Pn||dkr|} Pqn|r| j |q5n|rx]|ddkr|d }|j}|tt tkr|tt}n||}qWt|}n| j || sHtj|rHd} }qHn|s5t|tkrld}qlq5q5x| D]}|rt|}ntj|}|r | r|j d jd krd |j dt|j d f}qq d |j dd }n|rYtj|rYd}|r9|d}qY|rL|d}qY|d}n|j|qvW|sv|r| r|jd|jd| r|jdtq|jdn|r| r|jdn|j| x3| D]+}|rt|d}n|j|qW|j| | }x|r*||dkrxA|j}|sfdS|r~t|d}n|j|qPn||dkrt||}t||d|j}|sPn|j|q7nx>|j}|sdS|rt|d}n|j|qq7WdS(s@Convert an 8bit part of a MIME mail message to quoted-printable.iR is--s-- s is= isus-asciis%s%s%sis %sus-ascii%ssContent-Transfer-Encoding: sbase64 squoted-printable s7bit sMime-Version: 1.0 sContent-Type: text/plain; s charset="%s" scharset="us-ascii" s,Content-Transfer-Encoding: quoted-printable N(RRR tiso_charRtmvRtcteR&R'R*RRtappendRR%R tMAXLENRtchrsettlowerRSR(RQRt mimify_partR(R0R1tis_mimethas_ctetis_qpR5R3tmust_quote_bodytmust_quote_headert has_iso_charsRNt header_endtmessaget message_endR8R R:Rt chrset_resR;((s/usr/lib64/python2.7/mimify.pyR[s                          cCst|tdkrt|}t|tdkr||krddl}|jj|\}}|j||jj|d|qn|}t|tdkrt|d}n|}t|d}t ||d|j dS(s>Convert 8bit parts of a MIME mail message to quoted-printable.R iNR<R=i( R>R?R@RAR$RBR#RRR[RC(RDRER0R@RFRGR1R;((s/usr/lib64/python2.7/mimify.pyRs $ )t__main__s/Usage: mimify [-l len] -[ed] [infile [outfile]]isl:edbs-eR s-ds-bs-l(((iii(s-eR (s-dR (s-bR (s-dR (7RRXRSR%R+twarningstwarntDeprecationWarningt__all__tcompiletIR&R'tSR*RYRRR"R)RRR RR-RRKRJRQRRRRURVRTR[RtsysRRtargvtgetopttusageR2toptstargstexittotatencodeRt ValueErrort OverflowErrortstdintstdoutt encode_args(((s/usr/lib64/python2.7/mimify.pyts      U     4