U if~C@sdddddddddd d d d d dgZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl m Z ddl mZmZmZddlmZdZdZdZdZdZedZedZddZddZdBd!dZd"d#Zd$d%Zd&Z d&d'd(dZ!d)d*Z"d+d,Z#d-d.Z$d/d0Z%dCd2dZ&dDd3dZ'dEd4dZ(d5d Z)d&d'd6d Z*d7dZ+d8dZ,dFd9dZ-ed:ej.Z/d;dZ0dGd>dZ1dHd@dAZ2dS)Icollapse_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[\\"]cCs*z|WdStk r$YdSXdS)NFT)encodeUnicodeEncodeError)sr0/opt/alt/python38/lib64/python3.8/email/utils.py_has_surrogates4s rcCs|dd}|ddS)Nutf-8surrogateescapereplace)rdecode)stringZoriginal_bytesrrr _sanitizeAs r"rcCs|\}}|d|rz|dWn<tk r`t|trFt|}||}d||fYSXd}t|rtd}t d|}d||||fS|S)Nasciiz%s <%s>r"z\\\g<0>z %s%s%s <%s>) rr isinstancestrrZ header_encode specialsresearch escapesresub)ZpaircharsetnameZaddressZ encoded_nameZquotesrrrrMs      ccs\d}d}t|D]8\}}|r0|d|fVd}q|dkr>d}q||fVq|rX|dfVdS)NrF\T) enumerate)addrposescapechrrr_iter_escaped_charsns r3cCsd|kr |Sd}d}g}t|D]D\}}|dkr |dkr>|}q ||krX|||||d}d}q |t|kr|||dd|S)Nr$rr)r3appendlenjoin)r/startZopen_posresultr0r2rrr_strip_quoted_realnames}s  r:T)strictcCs|s&tdd|D}t|}|jSdd|D}t|}t|}t|}t|j}d}|D]}t|}|d|d7}q`t||krdgS|S) Ncss|]}t|VqdS)Nr&.0vrrr szgetaddresses..cSsg|] }t|qSrr<r=rrr sz getaddresses..rr4,rr) COMMASPACEr7 _AddressList addresslist_pre_parse_validation_post_parse_validationr:countr6)Z fieldvaluesr;allar/r9nr?rrrrs    cCsVt|}d}t|D]8\}}|dkr.|d7}q|dkr|d8}|dkrdSq|dkS)Nr(r4)F)r:r3)r/Zopensr0r2rrr_check_parenthesiss rOcCs(g}|D]}t|sd}||q|S)Nz('', ''))rOr5)Zemail_header_fieldsaccepted_valuesr?rrrrGs  rGcCs,g}|D]}d|dkrd}||q|S)N[r4rC)r5)Zparsed_email_header_tuplesrPr?rrrrHs   rHcCsfddddddddg|d |d d d d dddddddddg |dd|d|d|d|d|fS)Nz"%s, %02d %s %04d %02d:%02d:%02d %sZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecr4rr) timetuplezonerrr_format_timetuple_and_zones&  rYFcCsR|dkrt}|s|r,tj|tjj}n tj|}|rH|}d}t||S)NF)timedatetimeZ fromtimestamptimezoneutcZutcfromtimestamp astimezoner)timeval localtimeusegmtdtrrrrs cCsV|}|r2|jdks$|jtjjkr,tdd}n|jdkrBd}n |d}t||S)Nz%usegmt option requires a UTC datetimeZGMTz-0000z%z)rWtzinfor[r\r] ValueErrorstrftimerY)rbranowrXrrrrs  cCs^ttd}t}td}|dkr0d}nd|}|dkrHt}d|||||f}|S)Nd@r.z<%d.%d.%d%s@%s>)intrZosgetpidrandomZ getrandbitssocketZgetfqdn)ZidstringZdomainr_pidZrandintZmsgidrrrr "s  cCsNt|^}}|dkr(tj|ddStj|dddttj|diS)NrRrcseconds)rr[r\ timedelta)dataZdtupletzrrrr9s cCsv|st|j}|sdS|dSt|tr0|d}t|ts>dSt|gd}tt|j}|rjt|dkrndS|dS)NrCrr4)rErFr%listr&rGrHr6)r/r;Zaddrsrrrr As    cCs`t|dkr\|dr<|dr<|ddddddS|dr\|dr\|ddS|S) Nr4r$z\\r-z\"<>)r6 startswithendswithrr<rrrr`s   cCs&|td}t|dkr"dd|fS|S)NrS)splitTICKr6)rpartsrrrrls   cCsDtjj|d|pdd}|dkr*|dkr*|S|dkr6d}d|||fS)Nrr#)Zsafeencodingz%s'%s'%s)urllibparser)rr+languagerrrrts z&^(?P\w+)\*((?P[0-9]+)\*?)?$c Csl|dd}g}i}|d\}}|||f|r|d\}}|drRd}nd}t|}t|}|r|dd\}}|dk rt|}||g|||fq0||dt |fq0|rh| D]\}}g}d} | |D].\}} }|r t j j| dd } d} || qt t|}| rTt|\} } }||| | d|ffq||d|fq|S) Nr*TFr,numz"%s"zlatin-1)r~)popr5rzrrfc2231_continuationmatchgrouprj setdefaultritemssortrr EMPTYSTRINGr7r) ZparamsZ new_paramsZrfc2231_paramsr,valueZencodedZmorZ continuationsZextendedrr+rrrrrsD    rus-asciicCsnt|trt|dkrt|S|\}}}|dkr4|}t|d}zt|||WStk rht|YSXdS)NrTzraw-unicode-escape)r%tupler6rbytesr& LookupError)rerrorsZfallback_charsetr+rtextZrawbytesrrrrs  rvc Cs|dkrtjtjjS|jdk r.|S|dd|f}t|}t |}z tj |j d}t||j }Wnt k r|tjt|dd}tjo|jdk}|rtjntj }|tj |dkrt|tj|}n t|}YnX|j|dS)NrvrprRr)rc)r[rfr\r]r^rcrWrZmktimer`rr tm_gmtofftm_zoneAttributeErrorgmtimedaylighttm_isdstaltzonetznamer) rbZisdstZtmrqZlocaltmZdeltartZdstZgmtoffrrrr`s$   r`)r)NFF)F)NN)NN)rr)Nrv)3__all__rkrerZrmrnr[Z urllib.parserZemail._parseaddrrrrEr r r rZ email.charsetrrDrZ UEMPTYSTRINGZCRLFr|compiler'r)rr"rr3r:Zsupports_strict_parsingrrOrGrHrYrrr rr rrrASCIIrrrr`rrrrsz        !,       8