3 \I6@szdddddddddd d d d d dgZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl m Z ddl mZmZmZddlmZdZdZdZdZdZejdZejdZddZddZd7d!dZd"dZejd#ejej BZ!d$d%Z"d8d'dZ#d9d(dZ$d:d)dZ%d*d Z&d+d Z'd,dZ(d-dZ)d;d.dZ*ejd/ej+Z,d0dZ-dd5d6Z/dS)?collapse_rfc2231_value decode_paramsdecode_rfc2231encode_rfc2231 formataddr formatdateformat_datetime getaddresses make_msgid mktime_tz parseaddr parsedate parsedate_tzparsedate_to_datetimeunquoteN)quote) AddressList)r )r r _parsedate_tz)Charsetz, z 'z[][\\()<>@,:;".]z[\\"]c Cs&y |jdStk r dSXdS)NFT)encodeUnicodeEncodeError)sr#/usr/lib64/python3.6/email/utils.py_has_surrogates3s rcCs|jdd}|jddS)Nzutf-8surrogateescapereplace)rdecode)stringZoriginal_bytesrrr _sanitize@s r!utf-8c Cs|\}}|jd|ry|jdWn8tk r\t|trFt|}|j|}d||fSXd}tj|rpd}tj d|}d||||fS|S)Nasciiz%s <%s>r"z\\\g<0>z %s%s%s <%s>) rr isinstancestrrZ header_encode specialsresearch escapesresub)ZpaircharsetnameZaddressZ encoded_nameZquotesrrrrLs      cCstj|}t|}|jS)N) COMMASPACEjoin _AddressList addresslist)Z fieldvaluesallarrrrns a_ =\? # literal =? (?P[^?]*?) # non-greedy up to the next ? is the charset \? # literal ? (?P[qb]) # either a "q" or a "b", case insensitive \? # literal ? (?P.*?) # non-greedy up to the next ?= is the atom \?= # literal ?= cCsfddddddddg|d |d d d d dddddddddg |dd|d|d|d|d|fS)Nz"%s, %02d %s %04d %02d:%02d:%02d %sZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecrr) timetuplezonerrr_format_timetuple_and_zones r;FcCsR|dkrtj}|s|r,tjj|tjj}n tjj|}|rH|j}d}t||S)NF)timedatetimeZ fromtimestamptimezoneutcZutcfromtimestamp astimezoner)timeval localtimeusegmtdtrrrrs cCsV|j}|r2|jdks$|jtjjkr,tdd}n|jdkrBd}n |jd}t||S)Nz%usegmt option requires a UTC datetimeZGMTz-0000z%z)r9tzinfor=r>r? ValueErrorZstrftimer;)rDrCnowr:rrrrs  cCs^ttjd}tj}tjd}|dkr0d}nd|}|dkrHtj}d|||||f}|S)Nd@r.z<%d.%d.%d%s@%s>)intr<osgetpidrandomZ getrandbitssocketZgetfqdn)ZidstringZdomainrApidZrandintZmsgidrrrr s  cCsNt|^}}|dkr(tj|ddStj|dddtjtj|diS)Nr3rE)seconds)rr=r> timedelta)dataZdtupletzrrrrs cCst|j}|sdS|dS)Nrr)rr)r/r0)ZaddrZaddrsrrrr s cCs`t|dkr\|jdr<|jdr<|ddjddjddS|jdr\|jdr\|dd S|S) Nr5r$z\\\z\"<>rX)len startswithendswithr)r&rrrrs   cCs&|jtd}t|dkr"dd|fS|S)Nr4)splitTICKrY)rpartsrrrrs   cCsDtjj|d|pdd}|dkr*|dkr*|S|dkr6d}d|||fS)Nrr#)Zsafeencodingz%s'%s'%s)urllibparser)rr+languagerrrrs z&^(?P\w+)\*((?P[0-9]+)\*?)?$c Csx|dd}g}i}|jd\}}|j||fx|r|jd\}}|jdrTd}nd}t|}tj|}|r|jdd\}}|dk rt|}|j|gj|||fq2|j|dt |fq2W|rtx|j D]\}}g}d} |j x6|D].\}} }|rt j j| dd } d} |j| qWt tj|}| r^t|\} } }|j|| | d|ffq|j|d|fqW|S) Nr*TFr,numz"%s"zlatin-1)r_)popappendr[rrfc2231_continuationmatchgrouprK setdefaultritemssortr`ra EMPTYSTRINGr.r) ZparamsZ new_paramsZrfc2231_paramsr,valueZencodedZmordZ continuationsZextendedrr+rbrrrr sD   rus-asciic Csjt|t st|dkr t|S|\}}}|dkr6|}t|d}y t|||Stk rdt|SXdS)Nr6zraw-unicode-escape)r%tuplerYrbytesr& LookupError)rnerrorsZfallback_charsetr+rbtextZrawbytesrrrrEs   r5c Cs|dkrtjjtjjjS|jdk r.|jS|jdd|f}tj|}tj |}y tj |j d}tj||j }Wnt k r|tjtj|dd}tjo|jdk}|rtjntj }|tj |dkrtj|tj|}n tj|}YnX|j|dS)Nr5)rQr3r)rErX)r=rGr>r?r@rEr9r<ZmktimerBrRZ tm_gmtoffZtm_zoneAttributeErrorZgmtimeZdaylightZtm_isdstZaltzoneZtznamer) rDZisdstZtmrQZlocaltmZdeltarTdstZgmtoffrrrrB_s$   rB)r")NFF)F)NN)NN)rrorX)NrX)0__all__rLrer<rNrOr=Z urllib.parser`Zemail._parseaddrrrr/r r r rZ email.charsetrr-rmZ UEMPTYSTRINGZCRLFr]compiler'r)rr!rrVERBOSE IGNORECASEZecrer;rrr rr rrrASCIIrgrrrBrrrrsl        "     8