U e5dEã@sÞdZddddgZddlZddlZdZdZd Zd d d d dddddddddddddddddddd gZd!d"d#d$d%d&d'gZddddd(d)d*d(d+d*d,d+d-d,d.œZ d/d„Z d0d1„Z d2d„Z d3d„Z d4d„ZGd5d6„d6ƒZGd7d8„d8eƒZdS)9zcEmail address parsing code. Lifted directly from rfc822.py. This should eventually be rewritten. Ú mktime_tzÚ parsedateÚ parsedate_tzÚquoteéNú Úz, ZjanZfebZmarZaprZmayZjunZjulZaugÚsepÚoctZnovZdecZjanuaryZfebruaryZmarchZaprilZjuneZjulyZaugustZ septemberZoctoberZnovemberZdecemberZmonZtueZwedZthuZfriZsatZsunipþÿÿiÔþÿÿi þÿÿi¨ýÿÿiDýÿÿiàüÿÿ)ZUTZUTCZGMTÚZZASTZADTZESTZEDTZCSTZCDTZMSTZMDTZPSTZPDTcCs,t|ƒ}|sdS|ddkr$d|d<t|ƒS)zQConvert a date string to a time tuple. Accounts for military timezones. Né r)Ú _parsedate_tzÚtuple)ÚdataÚres©rú(/usr/lib64/python3.8/email/_parseaddr.pyr-s  c CsÈ|sdS| ¡}|sdS|d d¡s6|d ¡tkr>|d=n.|d d¡}|dkrl|d|dd…|d<t|ƒdkr¢|d d¡}t|ƒdkr¢||dd…}t|ƒdkr|d}| d¡}|d krÔ| d¡}|dkrþ|d|…||d…g|dd…<n | d ¡t|ƒd krdS|dd …}|\}}}}}| ¡}|tkrb|| ¡}}|tkrbdSt  |¡d}|d kr‚|d 8}|d dkrœ|dd …}| d ¡}|dkrº||}}|d dkrÔ|dd …}|d  ¡sì||}}|d dkr|dd …}| d ¡}t|ƒdkr,|\} } d} n~t|ƒdkrF|\} } } ndt|ƒdkr¦d|dkr¦|d d¡}t|ƒdkrŒ|\} } d} nt|ƒdkrª|\} } } ndSz,t |ƒ}t |ƒ}t | ƒ} t | ƒ} t | ƒ} Wnt k rîYdSX|dkr|dkr|d7}n|d7}d} |  ¡}|tkr6t|} n>z t |ƒ} Wnt k rXYnX| dkrt| d¡rtd} | r°| dkrd } | } nd} | | dd| dd} |||| | | ddd | g S)a†Convert date to extended time tuple. The last (additional) element is the time zone offset in seconds, except if the timezone was specified as -0000. In that case the last element is None. This indicates a UTC timestamp that explicitly declaims knowledge of the source timezone, as opposed to a +0000 timestamp that indicates the source timezone really was UTC. Nrú,ééú-éú+éÿÿÿÿréé ú:éÚ0Ú.édéDiliÐié<)ÚsplitÚendswithÚlowerÚ _daynamesÚrfindÚlenÚfindÚappendÚ _monthnamesÚindexÚisdigitÚintÚ ValueErrorÚupperÚ _timezonesÚ startswith)rÚiZstuffÚsZddZmmZyyZtmZtzZthhZtmmZtssZtzoffsetZtzsignrrrr 9s°     "                       r cCs&t|ƒ}t|tƒr|dd…S|SdS)z&Convert a time string to a time tuple.Nr )rÚ isinstancer ©rÚtrrrr°s  cCs<|ddkr"t |dd…d¡St |¡}||dSdS)zETurn a 10-tuple as returned by parsedate_tz() into a POSIX timestamp.r Né)r)ÚtimeÚmktimeÚcalendarZtimegmr5rrrr¹s  cCs| dd¡ dd¡S)zøPrepare string to be used in a quoted string. Turns backslash and double quote characters into quoted pairs. These are the only characters that need to be quoted inside a quoted string. Does not add the surrounding double quotes. ú\z\\ú"z\")Úreplace)ÚstrrrrrÃsc@s|eZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z ddd„Z dd„Z dd„Z dd„Zddd„Zdd„ZdS) Ú AddrlistClassaAddress parser class by Ben Escoto. To understand what this class does, it helps to have a copy of RFC 2822 in front of you. Note: this class interface is deprecated and may be removed in the future. Use email.utils.AddressList instead. cCsZd|_d|_d|_d|_|j|j|_|j|j|j|_|j dd¡|_||_g|_ dS)zƒInitialize a new instance. `field' is an unparsed address header field, containing one or more addresses. z ()<>@,:;."[]rz z rrN) ÚspecialsÚposÚLWSZCRÚFWSÚatomendsr=Ú phraseendsÚfieldÚ commentlist©ÚselfrFrrrÚ__init__×szAddrlistClass.__init__cCsŒg}|jt|jƒkr‚|j|j|jdkr\|j|jdkrL| |j|j¡|jd7_q|j|jdkr‚|j | ¡¡qq‚qt |¡S)z&Skip white space and extract comments.z rú() rAr'rFrBr)rGÚ getcommentÚ EMPTYSTRINGÚjoin)rIZwslistrrrÚgotonextêszAddrlistClass.gotonextcCs:g}|jt|jƒkr6| ¡}|r*||7}q| d¡q|S)zVParse all addresses. Returns a list containing all of the addresses. )rr)rAr'rFÚ getaddressr))rIÚresultZadrrrÚ getaddrlistøs  zAddrlistClass.getaddrlistcCsög|_| ¡|j}|j}| ¡}| ¡g}|jt|jƒkr\|rXt |j¡|dfg}n\|j|jdkr–||_||_| ¡}t |j¡|fg}n"|j|jdkrg}t|jƒ}|jd7_|jt|jƒkr¸| ¡|j|kr|j|jdkr|jd7_q¸||  ¡}qÄnš|j|jdkrx|  ¡}|jrft |¡dd |j¡d |fg}nt |¡|fg}n@|r–t |j¡|dfg}n"|j|j|j kr¸|jd7_| ¡|jt|jƒkrò|j|jd krò|jd7_|S) zParse the next address.rz.@rrú;úú@Tr)rFrArOr'Ú getdomainrX)rIZ expectrouteZadlistrrrrYAs. zAddrlistClass.getrouteaddrcCsTg}| ¡|jt|jƒkræd}|j|jdkrf|rH|d ¡sH| ¡| d¡|jd7_d}nd|j|jdkrŽ| dt| ¡ƒ¡n<|j|j|j kr¼|ræ|d ¡sæ| ¡qæn| |  ¡¡| ¡}|r |r | |¡q |jt|jƒks |j|jdkrt   |¡S| d¡|jd7_| ¡|  ¡}|sFt St   |¡|S) zParse an RFC 2822 addr-spec.TrrrFr<z"%s"r\)rOrAr'rFÚstripÚpopr)rÚgetquoterDÚgetatomrMrNr])rIZaslistZ preserve_wsZwsZdomainrrrrXas:  $  zAddrlistClass.getaddrspeccCsæg}|jt|jƒkrÜ|j|j|jkr6|jd7_q|j|jdkrX|j | ¡¡q|j|jdkrx| | ¡¡q|j|jdkr¢|jd7_| d¡q|j|jdkr¶tS|j|j|j krÌqÜq| |  ¡¡qt  |¡S)z-Get the complete domain name from an address.rrKú[rr\) rAr'rFrBrGr)rLÚgetdomainliteralrMrDrarN)rIZsdlistrrrr]‡s" zAddrlistClass.getdomainTcCsâ|j|j|krdSdg}d}|jd7_|jt|jƒkrØ|rX| |j|j¡d}np|j|j|krz|jd7_qØnN|r |j|jdkr | | ¡¡q,n(|j|jdkr¶d}n| |j|j¡|jd7_q,t |¡S)aæParse a header fragment delimited by special characters. `beginchar' is the start character for the fragment. If self is not looking at an instance of `beginchar' then getdelimited returns the empty string. `endchars' is a sequence of allowable end-delimiting characters. Parsing stops when one of these is encountered. If `allowcomments' is non-zero, embedded RFC 2822 comments are allowed within the parsed fragment. rFrrKr;T)rFrAr'r)rLrMrN)rIZ begincharZendcharsZ allowcommentsZslistrrrrÚ getdelimitedžs( zAddrlistClass.getdelimitedcCs| ddd¡S)z1Get a quote-delimited fragment from self's field.r<z" F©rd©rIrrrr`ÃszAddrlistClass.getquotecCs| ddd¡S)z7Get a parenthesis-delimited fragment from self's field.rKz) TrerfrrrrLÇszAddrlistClass.getcommentcCsd| ddd¡S)z!Parse an RFC 2822 domain-literal.z[%s]rbz] FrerfrrrrcËszAddrlistClass.getdomainliteralNcCsddg}|dkr|j}|jt|jƒkrZ|j|j|kr8qZn| |j|j¡|jd7_qt |¡S)aParse an RFC 2822 atom. Optional atomends specifies a different set of end token delimiters (the default is to use self.atomends). This is used e.g. in getphraselist() since phrase endings must not include the `.' (which is legal in phrases).rNr)rDrAr'rFr)rMrN)rIrDZatomlistrrrraÏszAddrlistClass.getatomcCs¦g}|jt|jƒkr¢|j|j|jkr6|jd7_q|j|jdkrV| | ¡¡q|j|jdkrx|j | ¡¡q|j|j|jkrŽq¢q| |  |j¡¡q|S)zýParse a sequence of RFC 2822 phrases. A phrase is a sequence of words, which are in turn either RFC 2822 atoms or quoted-strings. Phrases are canonicalized by squeezing all runs of continuous whitespace into one space. rr<rK) rAr'rFrCr)r`rGrLrEra)rIrZrrrrVãszAddrlistClass.getphraselist)T)N)Ú__name__Ú __module__Ú __qualname__Ú__doc__rJrOrRrPrYrXr]rdr`rLrcrarVrrrrr?Ís ; & % r?c@sHeZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dS)Ú AddressListz@An AddressList encapsulates a list of parsed RFC 2822 addresses.cCs&t ||¡|r| ¡|_ng|_dS©N)r?rJrRÚ addresslistrHrrrrJüs  zAddressList.__init__cCs t|jƒSrl)r'rmrfrrrÚ__len__szAddressList.__len__cCs>tdƒ}|jdd…|_|jD]}||jkr|j |¡q|Srl©rkrmr)©rIÚotherZnewaddrÚxrrrÚ__add__s   zAddressList.__add__cCs&|jD]}||jkr|j |¡q|Srl)rmr)©rIrqrrrrrÚ__iadd__s  zAddressList.__iadd__cCs.tdƒ}|jD]}||jkr|j |¡q|SrlrorprrrÚ__sub__s   zAddressList.__sub__cCs&|jD]}||jkr|j |¡q|Srl)rmÚremovertrrrÚ__isub__s  zAddressList.__isub__cCs |j|Srl)rm)rIr+rrrÚ __getitem__%szAddressList.__getitem__N) rgrhrirjrJrnrsrurvrxryrrrrrkús rk)rjÚ__all__r8r:rWrMZ COMMASPACEr*r%r0rr rrrr?rkrrrrÚsdüýû  w   /