HEX
Server: LiteSpeed
System: Linux baran.dnsprotection.me 4.18.0-553.83.1.lve.el8.x86_64 #1 SMP Wed Nov 12 10:04:12 UTC 2025 x86_64
User: ddir12 (3618)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/future/backports/email/__pycache__/feedparser.cpython-36.opt-1.pyc
3

�c�X�@s�dZddlmZddlmZddlmZddlmZmZmZddl	m
Z
mZddgZdd	l
Z
dd
lmZddlmZddlmZe
jd
�Ze
jd�Ze
jd�Ze
jd�Ze
jd�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� /usr/lib/python3.6/feedparser.py�__init__9szBufferedSubFile.__init__cCs|jj|�dS)N)r�append)rZpredrrr�push_eof_matcherCsz BufferedSubFile.push_eof_matchercCs
|jj�S)N)r�pop)rrrr�pop_eof_matcherFszBufferedSubFile.pop_eof_matchercCs|jj|j�d|_d|_dS)NrT)rrrr)rrrr�closeIszBufferedSubFile.closecCsT|js|jrdStS|jj�}x0|jddd�D]}||�r0|jj|�dSq0W|S)Nr����)rr�NeedMoreDatarrr)r�lineZateofrrr�readlineOs
zBufferedSubFile.readlinecCs|jj|�dS)N)rr)rr"rrr�
unreadlineaszBufferedSubFile.unreadlinecCs�|j|d}|_tj|�}|j�|_|jrT|rT|djd�rT|jd�|j�|_g}x:tt|�d�D]&}|j||d||dd�qjW|j|�dS)z$Push some new data into this object.rr�
�Nr ���)	r�NLCRE_crack�splitr�endswithr�lenr�	pushlines)r�data�parts�lines�irrr�pushfs

&zBufferedSubFile.pushcCs|ddd�|jdd�<dS)Nrrr )r)rr/rrrr,}szBufferedSubFile.pushlinescCs|S)Nr)rrrr�__iter__�szBufferedSubFile.__iter__cCs|j�}|dkrt�|S)Nr)r#�
StopIteration)rr"rrr�__next__�szBufferedSubFile.__next__N)�__name__�
__module__�__qualname__�__doc__rrrrr#r$r1r,r2r4rrrrr1s
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|kr|d}|d=nt}|�_|�_y|�jd��fdd��_Wntk
rddd��_YnXt��_g�_tr��j	�j
�_n�j	�j�_d�_
d�_d�_dS)N�policy)r9cs
d�jiS)Nr9)r9r)rrr�<lambda>�sz%FeedParser.__init__.<locals>.<lambda>cSsiS)Nrrrrrr:�sF)r�_factoryr9�
_factory_kwds�	TypeErrorr�_input�	_msgstackr	�	_parsegenr4�_parse�next�_cur�_last�_headersonly)rr;Z_3to2kwargsr9r)rrr�s&zFeedParser.__init__cCs
d|_dS)NT)rE)rrrr�_set_headersonly�szFeedParser._set_headersonlycCs|jj|�|j�dS)zPush more data into the parser.N)r>r1�_call_parse)rr-rrr�feed�szFeedParser.feedcCs&y|j�Wntk
r YnXdS)N)rAr3)rrrrrG�szFeedParser._call_parsecCsJ|jj�|j�|j�}|j�dkrF|j�rFtj�}|jj	||�|S)z<Parse all remaining data and return the root message object.�	multipart)
r>rrG�_pop_message�get_content_maintypeZis_multipartrZ!MultipartInvariantViolationDefectr9�
handle_defect)r�root�defectrrrr�s

zFeedParser.closecCs`|jf|j��}|jr.|jj�dkr.|jd�|jrD|jdj|�|jj|�||_||_dS)Nzmultipart/digestzmessage/rfc822rr )	r;r<rC�get_content_typeZset_default_typer?ZattachrrD)r�msgrrr�_new_message�s
zFeedParser._new_messagecCs(|jj�}|jr|jd|_nd|_|S)Nrr )r?rrC)r�retvalrrrrJ�s

zFeedParser._pop_messageccs6|j�g}xb|jD]X}|tkr(tVqtj|�sbtj|�s`tj�}|jj	|j
|�|jj|�P|j|�qW|j
|�|jr�g}x2|jj�}|tkr�tVq�|dkr�P|j|�q�W|j
jtj|��dS|j
j�dk�r�x�|jjtj�x$|j�D]}|tk�rtVq�Pq�W|j�}|jj�x&|jj�}|tk�rFtV�q(P�q(Wx&|jj�}|tk�rntV�qPP�qPW|dk�r�P|jj|�q�WdS|j
j�dk�r�x(|j�D]}|tk�r�tV�q�P�q�W|j�dS|j
j�dk�r�|j
j�}|dk�rbtj�}|jj	|j
|�g}x.|jD]$}|tk�r<tV�q$|j|��q$W|j
jtj|��dS|j
jdd�j�dk�r�tj�}|jj	|j
|�d	|}tjd
tj |�d�}	d}
g}d
}d
}
�x|jj�}|tk�r�tV�q�|dk�r�P|	j|�}|�r�|j!d��rd}
|j!d�}P|
�r~|�rj|d}t"j#|�}|�r\|dt$|j!d���|d<tj|�|j
_%d
}
|jj|��q�xB|jj�}|tk�r�tV�q�|	j|�}|�s�|jj|�P�q�W|jj|	j�x(|j�D]}|tk�r�tV�q�P�q�W|j&j�dk�rb|j&j'}|dk�r&d|j&_'n:|dk	�r�t"j#|�}|�r�t$|j!d��}|d|�|j&_'nD|j&j(}t)|t*��r�t"j#|�}|�r�|dt$|j!d���}||j&_(|jj�|j�|j
|_&n
|j|��q�W|
�r>tj+�}|jj	|j
|�|j
jtj|��g}x$|jD]}|tk�rtV�q�qWtj|�|j
_'dS|
�s`tj,�}|jj	|j
|�dS|�rndg}ng}x.|jD]$}|tk�r�tV�qz|j|��qzW|�r�|d}t-j|�}|�r�|t$|j!d��d�|d<tj|�|j
_'dSg}x.|jD]$}|tk�rtV�q�|j|��q�W|j
jtj|��dS)Nrzmessage/delivery-statusr
rIzcontent-transfer-encoding�8bit�7bit�binaryz--z(?P<sep>z4)(?P<end>--)?(?P<ws>[ \t]*)(?P<linesep>\r\n|\r|\n)?$TF�end�lineseprr)rTrSrUr r ).rQr>r!�headerRE�match�NLCRErZ MissingHeaderBodySeparatorDefectr9rLrCr$r�_parse_headersrEr#Zset_payload�EMPTYSTRING�joinrOrr@rJrrKZget_boundaryZNoBoundaryInMultipartDefect�get�lowerZ-InvalidMultipartContentTransferEncodingDefect�re�compile�escape�group�	NLCRE_eol�searchr+�preamblerD�epilogueZ_payload�
isinstance�strZStartBoundaryNotFoundDefectZCloseBoundaryNotFoundDefect�	NLCRE_bol)rZheadersr"rNr/rRrP�boundaryZ	separatorZ
boundaryreZcapturing_preamblerfrWZclose_boundary_seen�moZlastlineZeolmorgrVZpayload�	firstlineZbolmorrrr@�sf




































zFeedParser._parsegenc	Cs:d}g}�xt|�D�]\}}|ddkrV|sJtj|�}|jj|j|�q|j|�q|rx|jj|jj|��dg}}|j	d��r�|dkr�t
j|�}|r�|dt|j
d���}|jj|�qn:|t|�dkr�|jj|�dStj|�}|jjj|�q|jd�}|d|�}|g}qW|�r6|jj|jj|��dS)Nrrz 	zFrom r�:)�	enumeraterZ#FirstHeaderLineIsContinuationDefectr9rLrCrZset_rawZheader_source_parse�
startswithrdrer+rcZset_unixfromr>r$ZMisplacedEnvelopeHeaderDefectZdefects�find)	rr/Z
lastheaderZ	lastvalue�linenor"rNrlr0rrrr[�s>






zFeedParser._parse_headersN)r5r6r7r8r
ZMessagerrFrHrGrrQrJr@r[rrrrr
�s

~cs eZdZdZ�fdd�Z�ZS)rz(Like FeedParser, but feed accepts bytes.cst�j|jdd��dS)N�ascii�surrogateescape)rrH�decode)rr-)�	__class__rrrHszBytesFeedParser.feed)r5r6r7r8rH�
__classcell__rr)rvrr	s)r8Z
__future__rrrZfuture.builtinsrrrZfuture.utilsrr	�__all__r`Zfuture.backports.emailrr
Z"future.backports.email._policybaserrarZrjrdr(rXr\�NLr!rr
rrrrr�<module>s0




Z