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: //usr/lib/python3.6/site-packages/future/backports/email/__pycache__/feedparser.cpython-36.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|tk	st�|jj|�dS)N)r!�AssertionErrorrr)rr"rrr�
unreadlineaszBufferedSubFile.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)rr0rrrr-}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%r2r-r3r5rrrrr1s
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)r:cs
d�jiS)Nr:)r:r)rrr�<lambda>�sz%FeedParser.__init__.<locals>.<lambda>cSsiS)Nrrrrrr;�sF)r�_factoryr:�
_factory_kwds�	TypeErrorr�_input�	_msgstackr	�	_parsegenr5�_parse�next�_cur�_last�_headersonly)rr<Z_3to2kwargsr:r)rrr�s&zFeedParser.__init__cCs
d|_dS)NT)rF)rrrr�_set_headersonly�szFeedParser._set_headersonlycCs|jj|�|j�dS)zPush more data into the parser.N)r?r2�_call_parse)rr.rrr�feed�szFeedParser.feedcCs&y|j�Wntk
r YnXdS)N)rBr4)rrrrrH�szFeedParser._call_parsecCsV|jj�|j�|j�}|js&t�|j�dkrR|j�rRtj	�}|j
j||�|S)z<Parse all remaining data and return the root message object.�	multipart)r?rrH�_pop_messager@r$�get_content_maintypeZis_multipartrZ!MultipartInvariantViolationDefectr:�
handle_defect)r�root�defectrrrr�s

zFeedParser.closecCs`|jf|j��}|jr.|jj�dkr.|jd�|jrD|jdj|�|jj|�||_||_dS)Nzmultipart/digestzmessage/rfc822rr )	r<r=rD�get_content_typeZset_default_typer@ZattachrrE)r�msgrrr�_new_message�s
zFeedParser._new_messagecCs(|jj�}|jr|jd|_nd|_|S)Nrr )r@rrD)r�retvalrrrrK�s

zFeedParser._pop_messageccs@|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|
�s�t+�|j|��q�W|
�rHtj,�}|jj	|j
|�|j
jtj|��g}x$|jD]}|tk�rtV�q�qWtj|�|j
_'dS|
�sjtj-�}|jj	|j
|�dS|�rxdg}ng}x.|jD]$}|tk�r�tV�q�|j|��q�W|�r�|d}t.j|�}|�r�|t$|j!d��d�|d<tj|�|j
_'dSg}x.|jD]$}|tk�rtV�q|j|��qW|j
jtj|��dS)Nrzmessage/delivery-statusr
rJzcontent-transfer-encoding�8bit�7bit�binaryz--z(?P<sep>z4)(?P<end>--)?(?P<ws>[ \t]*)(?P<linesep>\r\n|\r|\n)?$TF�end�lineseprr)rUrTrVr r )/rRr?r!�headerRE�match�NLCRErZ MissingHeaderBodySeparatorDefectr:rMrDr%r�_parse_headersrFr#Zset_payload�EMPTYSTRING�joinrPrrArKrrLZget_boundaryZNoBoundaryInMultipartDefect�get�lowerZ-InvalidMultipartContentTransferEncodingDefect�re�compile�escape�group�	NLCRE_eol�searchr,�preamblerE�epilogueZ_payload�
isinstance�strr$ZStartBoundaryNotFoundDefectZCloseBoundaryNotFoundDefect�	NLCRE_bol)rZheadersr"rOr0rSrQ�boundaryZ	separatorZ
boundaryreZcapturing_preamblergrXZclose_boundary_seen�moZlastlineZeolmorhrWZpayload�	firstlineZbolmorrrrA�sh





































zFeedParser._parsegenc	CsLd}g}�x"t|�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�}|dk�std��|d|�}|g}qW|�rH|jj|jj|��dS)Nrrz 	zFrom r�:z3_parse_headers fed line with no : and no leading WS)�	enumeraterZ#FirstHeaderLineIsContinuationDefectr:rMrDrZset_rawZheader_source_parse�
startswithrerfr,rdZset_unixfromr?r%ZMisplacedEnvelopeHeaderDefectZdefects�findr$)	rr0Z
lastheaderZ	lastvalue�linenor"rOrmr1rrrr\�s@






zFeedParser._parse_headersN)r6r7r8r9r
ZMessagerrGrIrHrrRrKrAr\rrrrr
�s

~cs eZdZdZ�fdd�Z�ZS)rz(Like FeedParser, but feed accepts bytes.cst�j|jdd��dS)N�ascii�surrogateescape)rrI�decode)rr.)�	__class__rrrIszBytesFeedParser.feed)r6r7r8r9rI�
__classcell__rr)rwrr	s)r9Z
__future__rrrZfuture.builtinsrrrZfuture.utilsrr	�__all__raZfuture.backports.emailrr
Z"future.backports.email._policybaserrbr[rkrer)rYr]�NLr!rr
rrrrr�<module>s0




Z