HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/future/backports/email/__pycache__/feedparser.cpython-310.pyc
o

,�]�X�@s�dZddlmZddlmZddlmZddlmZmZmZddl	m
Z
mZddgZdd	l
Z
dd
lmZddlmZddlmZe
�d
�Ze
�d�Ze
�d�Ze
�d�Ze
�d�ZdZdZe�ZGdd�de�ZGdd�de�ZGdd�de�Zd	S)aFeedParser - An email feed parser.

The feed parser implements an interface for incrementally parsing an email
message, line by line.  This has advantages for certain applications, such as
those reading email messages off a socket.

FeedParser.feed() is the primary interface for pushing new data into the
parser.  It returns when there's nothing more it can do with the available
data.  When you have no more data to push into the parser, call .close().
This completes the parsing and returns the root message object.

The other advantage of this parser is that it will never raise a parsing
exception.  Instead, when it finds something unexpected, it adds a 'defect' to
the current message.  Defects are just instances that live on the message
object's .defects attribute.
�)�unicode_literals)�division)�absolute_import)�object�range�super)�implements_iterator�PY3�
FeedParser�BytesFeedParserN)�errors)�message)�compat32z
|
|
z(
|
|
)z
(
|
|
)\Zz(^(From |[\041-\071\073-\176]{1,}:|[\t ])��
c@s`eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�BufferedSubFileakA file-ish object that can have new data loaded into it.

    You can also push and pop line-matching predicates onto a stack.  When the
    current predicate matches the current line, a false EOF response
    (i.e. empty string) is returned instead.  This lets the parser adhere to a
    simple abstraction -- it parses until EOF closes the current message.
    cCsd|_g|_g|_d|_dS)NrF)�_partial�_lines�	_eofstack�_closed��self�r�C/usr/lib/python3/dist-packages/future/backports/email/feedparser.py�__init__9s
zBufferedSubFile.__init__cCs|j�|�dS�N)r�append)r�predrrr�push_eof_matcherCsz BufferedSubFile.push_eof_matchercCs
|j��Sr)r�poprrrr�pop_eof_matcherF�
zBufferedSubFile.pop_eof_matchercCs|j�|j�d|_d|_dS)NrT)rrrrrrrr�closeIs
zBufferedSubFile.closecCsR|js
|jrdStS|j��}|jddd�D]}||�r&|j�|�dSq|S)Nr���)rr�NeedMoreDatarrr)r�line�ateofrrr�readlineOs
�zBufferedSubFile.readlinecCs|tusJ�|j�|�dSr)r$rr�rr%rrr�
unreadlineaszBufferedSubFile.unreadlinecCs�|j|d}|_t�|�}|��|_|js)|r)|d�d�r)|�d�|��|_g}tt|�d�D]}|�||d||dd�q3|�|�dS)z$Push some new data into this object.rr#�
�����N)	r�NLCRE_crack�splitr�endswithr�lenr�	pushlines)r�data�parts�lines�irrr�pushfs

$zBufferedSubFile.pushcCs|ddd�|jdd�<dS)Nr#r)r)rr5rrrr2}szBufferedSubFile.pushlinescCs|Srrrrrr�__iter__�szBufferedSubFile.__iter__cCs|��}|dkr
t�|S)Nr)r'�
StopIterationr(rrr�__next__�szBufferedSubFile.__next__N)�__name__�
__module__�__qualname__�__doc__rrr r"r'r)r7r2r8r:rrrrr1s
rc@s^eZdZdZejfdd�Zdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�ZdS)r
zA feed-style parser of email.cs�d|vr|d}|d=nt}	|�_|�_z|�jd��fdd��_Wnty2dd��_Ynwt��_g�_trC��	�j
�_n��	�j�_d�_
d�_d�_dS)N�policy�r?cs
d�jiS)Nr?r@rrrr�<lambda>�s
z%FeedParser.__init__.<locals>.<lambda>cSsiSrrrrrrrA�sF)r�_factoryr?�
_factory_kwds�	TypeErrorr�_input�	_msgstackr	�	_parsegenr:�_parse�next�_cur�_last�_headersonly)rrB�_3to2kwargsr?rrrr�s&�
zFeedParser.__init__cCs
d|_dS)NT)rLrrrr�_set_headersonly�r!zFeedParser._set_headersonlycCs|j�|�|��dS)zPush more data into the parser.N)rEr7�_call_parse�rr3rrr�feed�szFeedParser.feedcCs$z|��WdStyYdSwr)rHr9rrrrrO�s
�zFeedParser._call_parsecCsR|j��|��|��}|jrJ�|��dkr'|��s't��}|j	�
||�|S)z<Parse all remaining data and return the root message object.�	multipart)rEr"rO�_pop_messagerF�get_content_maintype�is_multipartr�!MultipartInvariantViolationDefectr?�
handle_defect)r�root�defectrrrr"�s

�zFeedParser.closecCsd|jdi|����}|jr|j��dkr|�d�|jr$|jd�|�|j�|�||_||_dS)Nzmultipart/digestzmessage/rfc822r#r)	rBrCrJ�get_content_type�set_default_typerF�attachrrK)r�msgrrr�_new_message�s

zFeedParser._new_messagecCs*|j��}|jr|jd|_|Sd|_|S)Nr#)rFrrJ)r�retvalrrrrS�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
��dk�r�|j
��}|du�rt��}|j�	|j
|�g}|jD]}|tu�rtVq�|�|�q�|j
�t�|��dS|j
�dd���dv�r,t��}|j�	|j
|�d	|}t�d
t� |�d�}	d}
g}d}d}
	|j��}|tu�rTtV�qD|dk�rZn�|	�|�}|�r>|�!d
��rpd}
|�!d�}n�|
�r�|�r�|d}t"�#|�}|�r�|dt$|�!d���|d<t�|�|j
_%d}
|j�|��qD	|j��}|tu�r�tV�q�|	�|�}|�s�|j�|�n�q�|j�|	j�|��D]}|tu�r�tV�q�|j&��dk�r|j&j'}|dk�r�d|j&_'n@|du�r
t"�#|�}|�r
t$|�!d��}|d|�|j&_'n"|j&j(}t)|t*��r0t"�#|�}|�r0|dt$|�!d���}||j&_(|j��|��|j
|_&n
|
�sCJ�|�|��qE|
�r~t�+�}|j�	|j
|�|j
�t�|��g}|jD]
}|tu�rstV�qg�qgt�|�|j
_'dS|
�s�t�,�}|j�	|j
|�dS|�r�dg}ng}|jD]}|tu�r�tV�q�|�|��q�|�r�|d}t-�|�}|�r�|t$|�!d��d�|d<t�|�|j
_'dSg}|jD]}|tu�r�tV�q�|�|��q�|j
�t�|��dS)NTrzmessage/delivery-statusr
rRzcontent-transfer-encoding�8bit)�7bitr`�binaryz--z(?P<sep>z4)(?P<end>--)?(?P<ws>[ \t]*)(?P<linesep>\r\n|\r|\n)?$F�end�linesepr#r).r^rEr$�headerRE�match�NLCREr� MissingHeaderBodySeparatorDefectr?rWrJr)r�_parse_headersrLr'�set_payload�EMPTYSTRING�joinrZrrGrSr rT�get_boundary�NoBoundaryInMultipartDefect�get�lower�-InvalidMultipartContentTransferEncodingDefect�re�compile�escape�group�	NLCRE_eol�searchr1�preamblerK�epilogue�_payload�
isinstance�str�StartBoundaryNotFoundDefect�CloseBoundaryNotFoundDefect�	NLCRE_bol)r�headersr%rYr5r_r]�boundary�	separator�
boundaryre�capturing_preamblerxrd�close_boundary_seen�mo�lastline�eolmoryrc�payload�	firstline�bolmorrrrG�s|�





�


��!



���








�




�




�S

�




zFeedParser._parsegenc	CsBd}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�}|dks�Jd��|d|�}|g}q|r�|jj|j�|��dSdS)Nrrz 	zFrom r-�:z3_parse_headers fed line with no : and no leading WS)�	enumerater�#FirstHeaderLineIsContinuationDefectr?rWrJr�set_raw�header_source_parse�
startswithrvrwr1ru�set_unixfromrEr)�MisplacedEnvelopeHeaderDefect�defects�find)	rr5�
lastheader�	lastvalue�linenor%rYr�r6rrrri�sB






�zFeedParser._parse_headersN)r;r<r=r>r
�MessagerrNrQrOr"r^rSrGrirrrrr
�s

~cs eZdZdZ�fdd�Z�ZS)rz(Like FeedParser, but feed accepts bytes.cst��|�dd��dS)N�ascii�surrogateescape)rrQ�decoderP��	__class__rrrQszBytesFeedParser.feed)r;r<r=r>rQ�
__classcell__rrr�rr	s)r>�
__future__rrr�future.builtinsrrr�future.utilsrr	�__all__rr�future.backports.emailrr
�"future.backports.email._policybaserrsrgrrvr.rerk�NLr$rr
rrrrr�<module>s2




Z