o ?OgüXã@s´ ddgZddlZddlmZddlmZddlmZddlm Z e  d¡Z e  d ¡Z e  d ¡Z e  d ¡Ze  d ¡Zd Zd ZeƒZGdd„deƒZGdd„dƒZGdd„deƒZdS)Ú FeedParserÚBytesFeedParseréN)Úerrors)Úcompat32)Údeque)ÚStringIOz \r\n|\r|\nz (\r\n|\r|\n)z(\r\n|\r|\n)\Zz%^(From |[\041-\071\073-\176]*:|[\t ])ÚÚ c@s^eZdZ dd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dS)ÚBufferedSubFilecCs$tdd|_tƒ|_g|_d|_dS)Nr)ÚnewlineF)rÚ_partialrÚ_linesÚ _eofstackÚ_closed©Úself©rú7/opt/alt/python310/lib64/python3.10/email/feedparser.pyÚ__init__5s  zBufferedSubFile.__init__cCó|j |¡dS©N)rÚappend)rZpredrrrÚpush_eof_matcher@óz BufferedSubFile.push_eof_matchercCs |j ¡Sr)rÚpoprrrrÚpop_eof_matcherCó zBufferedSubFile.pop_eof_matchercCs<|j d¡| |j ¡¡|j d¡|j ¡d|_dS)NrT)r ÚseekÚ pushlinesÚ readlinesÚtruncaterrrrrÚcloseFs    zBufferedSubFile.closecCsL|js |jrdStS|j ¡}t|jƒD]}||ƒr#|j |¡dSq|S©Nr)r rÚ NeedMoreDataÚpopleftÚreversedrÚ appendleft)rÚlineZateofrrrÚreadlineNs  ýzBufferedSubFile.readlinecCrr)r r&©rr'rrrÚ unreadline`szBufferedSubFile.unreadlinecCsz |j |¡d|vrd|vrdS|j d¡|j ¡}|j d¡|j ¡|d d¡s6|j | ¡¡| |¡dS)Nr ú réÿÿÿÿ)r Úwriterrr Úendswithrr)rÚdataÚpartsrrrÚpushes     zBufferedSubFile.pushcCrr)r Úextend)rÚlinesrrrrzrzBufferedSubFile.pushlinescCs|SrrrrrrÚ__iter__}szBufferedSubFile.__iter__cCs| ¡}|dkr t‚|Sr")r(Ú StopIterationr)rrrÚ__next__€szBufferedSubFile.__next__N) Ú__name__Ú __module__Ú __qualname__rrrr!r(r*r1rr4r6rrrrr -s  r c@s^eZdZ dedœdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dS)rN©ÚpolicycCsž ||_d|_|dur|jdurddlm}||_n|j|_n||_z||jdWn ty6d|_Ynwtƒ|_g|_ |  ¡j |_ d|_ d|_d|_dS)NFr)ÚMessager:T)r;Ú_old_style_factoryZmessage_factoryZ email.messager<Ú_factoryÚ TypeErrorr Ú_inputÚ _msgstackÚ _parsegenr6Ú_parseÚ_curÚ_lastÚ _headersonly)rr>r;r<rrrr‹s(     þ  zFeedParser.__init__cCs d|_dS)NT)rFrrrrÚ_set_headersonlyªrzFeedParser._set_headersonlycCs |j |¡| ¡dSr)r@r1Ú _call_parse©rr/rrrÚfeed­s  zFeedParser.feedcCs$z| ¡WdStyYdSwr)rCr5rrrrrH²s  ÿzFeedParser._call_parsecCsJ |j ¡| ¡| ¡}| ¡dkr#| ¡s#t ¡}|j  ||¡|S)NÚ multipart) r@r!rHÚ _pop_messageÚget_content_maintypeZ is_multipartrZ!MultipartInvariantViolationDefectr;Ú handle_defect)rÚrootÚdefectrrrr!¸s  ÿzFeedParser.closecCsn|jr| ¡}n|j|jd}|jr|j ¡dkr| d¡|jr)|jd |¡|j |¡||_||_ dS)Nr:zmultipart/digestzmessage/rfc822r,) r=r>r;rDÚget_content_typeZset_default_typerAZattachrrE)rÚmsgrrrÚ _new_messageÅs    zFeedParser._new_messagecCs*|j ¡}|jr|jd|_|Sd|_|S)Nr,)rArrD)rÚretvalrrrrLÒs  ÿzFeedParser._pop_messageccsæ| ¡g}|jD]-}|turtVq t |¡s2t |¡s0t ¡}|j  |j |¡|j  |¡n|  |¡q |  |¡|jrfg} |j ¡}|turPtVqB|dkrUn|  |¡qC|j  t |¡¡dS|j  ¡dkr¹ |j tj¡| ¡D] }|turƒtVqy| ¡}|j ¡ |j ¡}|tur›tVq |j ¡}|turªtVqœ |dkr² dS|j  |¡qn|j  ¡dkrÕ| ¡D] }|turÎtVqÄ| ¡dS|j  ¡dkrÐ|j  ¡}|durt ¡}|j  |j |¡g}|jD]}|turtVqø|  |¡qø|j  t |¡¡dSt|j  dd¡ƒ ¡dvr.t ¡}|j  |j |¡d |}t  d t !|¡d ¡} d} g} d } d } |j ¡}|turVtVqF|dkr\në|  |¡}|r@| "d ¡rrd} | "d¡} nÕ| r£| r™| d}t# $|¡}|r’|dt%| "d¡ƒ …| d<t | ¡|j _&d } |j  |¡qF |j ¡}|tur³tVq£|  |¡}|sÂ|j  |¡nq¤|j | j¡| ¡D] }|turÛtVqÏ|j' ¡dkr|j'j(}|dkròd|j'_(n@|durt# $|¡}|rt%| "d¡ƒ}|d| …|j'_(n"|j'j)}t*|tƒr2t# $|¡}|r2|dt%| "d¡ƒ …}||j'_)|j ¡| ¡|j |_'n|   |¡qG| r{t +¡}|j  |j |¡|j  t | ¡¡g}|jD] }|turptVqdqdt |¡|j _(dS| sŒt ,¡}|j  |j |¡dS| r“dg}ng}|jD]}|tur¤tVq˜|  |¡q˜|rÇ|d}t- |¡}|rÇ|t%| "d¡ƒd…|d<t |¡|j _(dSg}|jD]}|turátVqÕ|  |¡qÕ|j  t |¡¡dS)NTrzmessage/delivery-statusÚmessagerKzcontent-transfer-encodingÚ8bit)Z7bitrVZbinaryz--z(?Pz4)(?P--)?(?P[ \t]*)(?P\r\n|\r|\n)?$FÚendÚlinesepr,r).rSr@r#ÚheaderREÚmatchÚNLCRErZ MissingHeaderBodySeparatorDefectr;rNrDr*rÚ_parse_headersrFr(Z set_payloadÚ EMPTYSTRINGÚjoinrQrrBrLrrMZ get_boundaryZNoBoundaryInMultipartDefectÚstrÚgetÚlowerZ-InvalidMultipartContentTransferEncodingDefectÚreÚcompileÚescapeÚgroupÚ NLCRE_eolÚsearchÚlenÚpreamblerEÚepilogueZ_payloadÚ isinstanceZStartBoundaryNotFoundDefectZCloseBoundaryNotFoundDefectÚ NLCRE_bol)rZheadersr'rPr3rTrRÚboundaryZ separatorZ boundaryreZcapturing_preamblerirXZclose_boundary_seenÚmoZlastlineZeolmorjrWZpayloadÚ firstlineZbolmorrrrBÚsz€        ù     ÿá!      ÿ ÿÿ            ø      €     ±S  þ     zFeedParser._parsegenc CsTd}g}t|ƒD]‘\}}|ddvr(|s"t |¡}|j |j|¡q| |¡q|r9|jj|j |¡Ždg}}|  d¡rz|dkr\t   |¡}|rU|dt |  d¡ƒ …}|j |¡q|t |ƒdkrm|j |¡dSt |¡}|jj |¡q| d¡}|dkrt d¡}|jj |¡q|d|…}|g}q|r¨|jj|j |¡ŽdSdS)Nrrz zFrom éú:zMissing header name.)Ú enumeraterZ#FirstHeaderLineIsContinuationDefectr;rNrDrZset_rawZheader_source_parseÚ startswithrfrgrhreZ set_unixfromr@r*ZMisplacedEnvelopeHeaderDefectZdefectsÚfindZInvalidHeaderDefect) rr3Z lastheaderZ lastvalueÚlinenor'rPrnÚirrrr\×sH            ÿzFeedParser._parse_headersr) r7r8r9rrrGrJrHr!rSrLrBr\rrrrrˆs   ~cseZdZ ‡fdd„Z‡ZS)rcstƒ | dd¡¡dS)NÚasciiÚsurrogateescape)ÚsuperrJÚdecoderI©Ú __class__rrrJszBytesFeedParser.feed)r7r8r9rJÚ __classcell__rrr{rrs)Ú__all__rbZemailrZemail._policybaserÚ collectionsrÚiorrcr[rlrfZ NLCRE_crackrYr]ÚNLÚobjectr#r rrrrrrÚs*         [