bgPdZddlmZddlmZddlmZddlmZddlmZddlm Z ddl m Z dd l m Z dd l m ZGd d eZGd deZGddeZdZGddeZGddeZGddeZGddeZGddeZGddeZGddeZGd d!eZGd"d#eZGd$d%eZGd&d'eZGd(d)eZGd*d+eZ id,ed-ed.ed/ed0ed1ed2ed3ed4ed5ed6ed7ed8ed9ed:ed;edd?eZ"d@S)Aa;Representing and manipulating email headers via custom objects. This module provides an implementation of the HeaderRegistry API. The implementation is designed to flexibly follow RFC5322 rules. Eventually HeaderRegistry will be a public API, but it isn't yet, and will probably change some before that happens. )unicode_literals)division)absolute_import)superstr)text_to_native_str)utils)errors)_header_value_parserceZdZd dZedZedZedZedZdZ d Z d Z dS) AddressNc|q|s|rtdtj|\}}|r#td|||jr |jd|j}|j}||_||_ ||_ dS)aCreate an object represeting a full email address. An address can have a 'display_name', a 'username', and a 'domain'. In addition to specifying the username and domain separately, they may be specified together by using the addr_spec keyword *instead of* the username and domain keywords. If an addr_spec string is specified it must be properly quoted according to RFC 5322 rules; an error will be raised if it is not. An Address object has display_name, username, domain, and addr_spec attributes, all of which are read-only. The addr_spec and the string value of the object are both quoted according to RFC5322 rules, but without any Content Transfer Encoding. Nz=addrspec specified when username and/or domain also specifiedz6Invalid addr_spec; only '{}' could be parsed from '{}'r) TypeErrorparser get_addr_spec ValueErrorformat all_defects local_partdomain _display_name _username_domain)self display_nameusernamer addr_speca_srests v/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/future/backports/email/headerregistry.py__init__zAddress.__init__s(   96 9!8999,Y77IC 5 "==CV$'>4>4555 )oa((~HZF)! c|jSNrrs r"rzAddress.display_name< !!r$c|jSr&)rr(s r"rzAddress.username@ ~r$c|jSr&)rr(s r"rzAddress.domainD |r$ct|j}t|t|tjz krtj|j}n|j}|jr |dz|jzS|sdS|S)zThe addr_spec (username@domain) portion of the address, quoted according to RFC 5322 rules, but with no Content Transfer Encoding. @<>)setrlenr DOT_ATOM_ENDS quote_stringr)rnamesetlps r"rzAddress.addr_specHs| dm$$ w<<#gf&::;; ; ;$T]33BBB ; *8dk) ) 4 r$cNd|j|j|jS)Nz6Address(display_name={!r}, username={!r}, domain={!r}))rrrrr(s r"__repr__zAddress.__repr__Xs+GNN)4=$+GG Gr$c,t|j}t|t|tjz krtj|j}n|j}|r*|jdkrdn|j}d||S|jS)Nr0rz{} <{}>)r1rr2rSPECIALSr4rr)rr5disprs r"__str__zAddress.__str__\sd'(( w<<#gfo566 6 6&t'899DD$D  5"nd22I##D)44 4~r$ct|t|krdS|j|jko|j|jko|j|jkSNF)typerrrrothers r"__eq__zAddress.__eq__gsS ;;$t** $ $5!U%77, /, u|+ -r$)rrrN) __name__ __module__ __qualname__r#propertyrrrrr8r<rBr$r"rrs####J""X"XX  X GGG   -----r$rcTeZdZddZedZedZdZdZdZ dS) GroupNc\||_|rt|n t|_dS)aCreate an object representing an address group. An address group consists of a display_name followed by colon and an list of addresses (see Address) terminated by a semi-colon. The Group is created by specifying a display_name and a possibly empty list of Address objects. A Group can also be used to represent a single address that is not in a group, which is convenient when manipulating lists that are a combination of Groups and individual Addresses. In this case the display_name should be set to None. In particular, the string representation of a Group whose display_name is None is the same as the Address object, if there is one and only one Address object in the addresses list. N)rtuple _addresses)rr addressess r"r#zGroup.__init__qs-*.7D% ***UWWr$c|jSr&r'r(s r"rzGroup.display_namer)r$c|jSr&)rLr(s r"rMzGroup.addressess r$cBd|j|jS)Nz'Group(display_name={!r}, addresses={!r})rrrMr(s r"r8zGroup.__repr__s$8??"DN44 4r$c|j2t|jdkrt|jdS|j}|Pt |}t|t|t jz krt j|}dd|jD}|rd|zn|}d ||S)Nr, c34K|]}t|VdSr&r).0xs r" z Group.__str__..s(::a3q66::::::r$ z{}:{};) rr2rMrr1rr:r4joinr)rr;r5adrstrs r"r<z Group.__str__s   $T^)<):::::!'3vVtV,,,r$ct|t|krdS|j|jko|j|jkSr>)r?rrMr@s r"rBz Group.__eq__sB ;;$t** $ $5!U%772%/1 3r$)NN) rCrDrEr#rFrrMr8r<rBrGr$r"rIrIosEEEE$""X"X444 - - -33333r$rIcleZdZdZdZdZedZedZdZ e dZ dZ d S) BaseHeadera|Base class for message headers. Implements generic behavior and provides tools for subclasses. A subclass must define a classmethod named 'parse' that takes an unfolded value string and a dictionary as its arguments. The dictionary will contain one key, 'defects', initialized to an empty list. After the call the dictionary must contain two additional keys: parse_tree, set to the parse tree obtained from parsing the header, and 'decoded', set to the string value of the idealized representation of the data from the value. (That is, encoded words are decoded, and values that have canonical representations are so represented.) The defects key is intended to collect parsing defects, which the message parser will subsequently dispose of as appropriate. The parser should not, insofar as practical, raise any errors. Defects should be added to the list instead. The standard header parsers register defects for RFC compliance issues, for obsolete RFC syntax, and for unrecoverable parsing errors. The parse method may add additional keys to the dictionary. In this case the subclass must define an 'init' method, which will be passed the dictionary as its keyword arguments. The method should use (usually by setting them as the value of similarly named attributes) and remove all the extra keys added by its parse method, and then use super to call its parent class with the remaining arguments and keywords. The subclass should also make sure that a 'max_count' attribute is defined that is either None or 1. XXX: need to better define this API. cdgi}|||tj|drtj|d|d<t j||d}|j|fi||S)Ndefectsdecoded)parser _has_surrogates _sanitizer__new__init)clsnamevaluekwdsrs r"rdzBaseHeader.__new__s2 %  i 1 1 ?#od9o>>DO{3Y00 $$ r$c \|d}|d=|d}|d=||_||_||_dS)Nr_ parse_tree)_name _parse_tree_defects)rrg _3to2kwargsr_rks r"rezBaseHeader.inits>i(k).D . K 4M % r$c|jSr&)rlr(s r"rgzBaseHeader.names zr$c*t|jSr&)rKrnr(s r"r_zBaseHeader.defectssT]###r$cht|jj|jjt |f|jfSr&)_reconstruct_header __class__rC __bases__r__dict__r(s r" __reduce__zBaseHeader.__reduce__s4 '(D   M r$c,tj||Sr&)rrd)rfrhs r" _reconstructzBaseHeader._reconstructs{3&&&r$c H|d}|d= tjtjtj|jdtjddgtjtjddg|jg}||S)Npolicyz header-name:z header-seprXfws)r{) rHeader HeaderLabel ValueTerminalrgCFWSListWhiteSpaceTerminalrmfold)rror{headers r"rzBaseHeader.foldsX&K,A   $TY >>$S,77 9 : : OV6sEBBC D D!-  /00 {{&{)))r$N) rCrDrE__doc__rdrerFrgr_rw classmethodryrrGr$r"r]r]s@   X$$X$''['*****r$r]cdtt||i|Sr&)r?r ry)cls_namebasesrhs r"rsrss+ "8,,eR 8 8 E Ee L LLr$cHeZdZdZeejZedZ dS)UnstructuredHeaderNcf|||d<t|d|d<dS)Nrkr`) value_parserrrfrhris r"razUnstructuredHeader.parses4 --e44\d<011Yr$) rCrDrE max_count staticmethodrget_unstructuredrrrarGr$r"rr sDI< 788L22[222r$rceZdZdZdS)UniqueUnstructuredHeaderrRNrCrDrErrGr$r"rrIIIr$rcreZdZdZdZeejZe dZ fdZ e dZ xZS) DateHeaderaHeader whose value consists of a single timestamp. Provides an additional attribute, datetime, which is either an aware datetime using a timezone, or a naive datetime if the timezone in the input string is -0000. Also accepts a datetime as input. The 'value' attribute is the normalized form of the timestamp, which means it is the output of format_datetime on the datetime. Ncx|sN|dtjd|d<d|d<tj|d<dSt |t rtj|}||d<tj |d|d<| |d|d<dS)Nr_datetimerr`rk) appendr HeaderMissingRequiredValuer TokenList isinstancerr parsedate_to_datetimeformat_datetimerrs r"razDateHeader.parse,s  O " "6#D#F#F G G G#D  DO!'!1!3!3D  F eS ! ! 7/66E Z/Z0@AAY --d9o>>\r$cn|d|_tj|i|dS)Nr)pop _datetimerrerargskwrts r"rezDateHeader.init:s7 ++ d!b!!!!!r$c|jSr&)rr(s r"rzDateHeader.datetime>r+r$)rCrDrErrrrrrrrarerFr __classcell__rts@r"rrsI < 788L ? ?[ ?"""""Xr$rceZdZdZdS)UniqueDateHeaderrRNrrGr$r"rrCrr$rczeZdZdZedZedZfdZe dZ e dZ xZ S) AddressHeaderNcLtj|\}}|r Jd|S)Nzthis should not happen)rget_address_list)rh address_lists r"rzAddressHeader.value_parserLs1$5e<< e22222yr$ct|trr||x|d<}g}|jD]9}|t |jd|jD:t|j }n!t|ds|g}d|D}g}||d<||d<d d|D|d <d|vr ||d |d<dSdS) NrkcZg|](}t|jpd|jpd|jpd)S)r)rrrr)rUmbs r" z'AddressHeader.parse..[sV%C%C%C*,&-R_-B-/]-@b-/Y_"&>&>%C%C%Cr$__iter__cTg|]%}t|dstd|gn|&S)rMN)hasattrrIrUitems r"rz'AddressHeader.parse..dsK777(,29{1K1K4eD4&)))/3777r$groupsr_rSc,g|]}t|SrGrrs r"rz'AddressHeader.parse..js$B$B$B4SYY$B$B$Br$r`) rrrrMrrIr all_mailboxeslistrrrY)rfrhrirraddrr_s r"razAddressHeader.parseRsc eS ! ! 140@0@0G0G GD F$. E E eD$5%C%C04/A%C%C%CDDEEEE <344GG5*-- 7705777FGX!Y))$B$B6$B$B$BCCY t # #!$!1!1$y/!B!BD    $ #r$ct|d|_d|_t j|i|dS)Nr)rKr_groupsrLrrers r"rezAddressHeader.initnsFRVVH--..  d!b!!!!!r$c|jSr&)rr(s r"rzAddressHeader.groupssr-r$cd|j#td|jD|_|jS)Nc&g|]}|jD]}|SrG)rM)rUgroupaddresss r"rz+AddressHeader.addresses..zsG%M%M%M||x|d<}t||d<|d|j|jdn|j|d<|j|d<|j'd|d|d|d<dSd|d<dS)Nrkr`r_majorminorz{}.{}version)rrextendrrrrrfrhrirks r"razMIMEVersionHeader.parses*-*:*:5*A*AA\Zj//Y Yz5666 * 0 8j>NW "(W   '%nnT']DMJJDOOO"DOOOr$c|d|_|d|_|d|_t j|i|dS)Nrrr)r_version_major_minorrrers r"rezMIMEVersionHeader.initsYy)) ffWoo ffWoo  d!b!!!!!r$c|jSr&)rr(s r"rzMIMEVersionHeader.major {r$c|jSr&)rr(s r"rzMIMEVersionHeader.minorrr$c|jSr&)rr(s r"rzMIMEVersionHeader.version }r$)rCrDrErrrparse_mime_versionrrrarerFrrrrrs@r"rrsI< 9::L # #[ #""""" XXXr$rcNeZdZdZedZfdZedZxZ S)ParameterizedMIMEHeaderrRc||x|d<}t||d<|d|j|ji|d<dSt d|jD|d<dS)Nrkr`r_paramsc3K|]A\}}tj|tj|fVBdSr&)r rclower)rUrgrhs r"rWz0ParameterizedMIMEHeader.parse..sj"H"H&1dE$)?4#8#8#>#>#@#@#(?5#9#9#;"H"H"H"H"H"Hr$)rrrrrdictrs r"razParameterizedMIMEHeader.parses*-*:*:5*A*AA\Zj//Y Yz5666   $DNNN""H"H5?5F"H"H"HHHDNNNr$cn|d|_tj|i|dS)Nr)r_paramsrrers r"rezParameterizedMIMEHeader.inits7vvh''  d!b!!!!!r$c4|jSr&)rcopyr(s r"rzParameterizedMIMEHeader.paramss|  """r$) rCrDrErrrarerFrrrs@r"rrsv I H H[ H"""""##X#####r$rceZdZeejZfdZedZ edZ edZ xZ S)ContentTypeHeaderctj|i|tj|jj|_tj|jj|_dSr&) rrer rcrmmaintype _maintypesubtype_subtypers r"rezContentTypeHeader.initsP d!b!!!)9)BCC(8(@AA r$c|jSr&)rr(s r"rzContentTypeHeader.maintyper+r$c|jSr&)rr(s r"rzContentTypeHeader.subtyperr$c&|jdz|jzS)N/)rrr(s r" content_typezContentTypeHeader.content_types}s"T\11r$) rCrDrErrparse_content_type_headerrrerFrrrrrs@r"rrs< @AALBBBBB XX22X22222r$rcTeZdZeejZfdZedZ xZ S)ContentDispositionHeaderctj|i||jj}||nt j||_dSr&)rrermcontent_dispositionr rc_content_disposition)rrrcdrts r"rezContentDispositionHeader.initsI d!b!!!   1*,*BB%/":M:M!!!r$c|jSr&)rr(s r"rz,ContentDispositionHeader.content_dispositions ((r$) rCrDrErr parse_content_disposition_headerrrerFrrrs@r"rrsj< GHHLNNNNN ))X)))))r$rcneZdZdZeejZedZ fdZ e dZ xZ S)ContentTransferEncodingHeaderrRc||x|d<}t||d<|d|jdS)Nrkr`r_)rrrrrs r"raz#ContentTransferEncodingHeader.parsesO*-*:*:5*A*AA\Zj//Y Yz566666r$ctj|i|tj|jj|_dSr&)rrer rcrmcte_cters r"rez"ContentTransferEncodingHeader.inits9 d!b!!!OD$4$899 r$c|jSr&)rr(s r"rz!ContentTransferEncodingHeader.cte s yr$)rCrDrErrr&parse_content_transfer_encoding_headerrrrarerFrrrs@r"rrsI< MNNL77[7 :::::Xr$rsubjectdatez resent-datez orig-datesenderz resent-sendertoz resent-toccz resent-ccbccz resent-bccfromz resent-fromzreply-toz mime-versionz content-type)zcontent-dispositionzcontent-transfer-encodingc2eZdZdZeedfdZdZdZdZ dS)HeaderRegistryz%A header_factory and header registry.Tcvi|_||_||_|r!|jtdSdS)aCreate a header_factory that works with the Policy API. base_class is the class that will be the last class in the created header class's __bases__ list. default_class is the class that will be used if "name" (see __call__) does not appear in the registry. use_default_map controls whether or not the default mapping of names to specialized classes is copied in to the registry when the factory is created. The default is True. N)registry base_class default_classupdate_default_header_map)rrruse_default_maps r"r#zHeaderRegistry.__init__*sI $*  6 M !4 5 5 5 5 5 6 6r$c>||j|<dS)zLRegister cls as the specialized class for handling "name" headers. N)rrrrgrfs r" map_to_typezHeaderRegistry.map_to_type<s'* djjll###r$c|j||j}t t d|jz||jfiS)N_)rgetrrr?r rCrrs r" __getitem__zHeaderRegistry.__getitem__BsNm d.@AA&s3<'7883:PRTUUUr$c&||||S)aCreate a header instance for header 'name' from 'value'. Creates a header instance by creating a specialized class for parsing and representing the specified header by combining the factory base_class with a specialized class from the registry or the default_class, and passing the name and value to the constructed class's constructor. rG)rrgrhs r"__call__zHeaderRegistry.__call__FstDz$&&&r$N) rCrDrErr]rr#rrrrGr$r"rr&sg//",r$s('''''&&&&&&!!!!!!++++++(((((())))))AAAAAAW-W-W-W-W-fW-W-W-t0303030303F030303ja*a*a*a*a*a*a*a*HMMM222222221 $$$$$$$$Nz 44444F444n- !!!!!-!!! 3 """"""""J#####f###:22222/222, ) ) ) ) )6 ) ) )F. $< $4J$4   $=  $7  $7M $7M $7M $7M$7 $5!"$5#$%=$A',*'*'*'*'*'V*'*'*'*'*'r$