404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.135.184.124: ~ $
3

�Qg���@svddlZddlZddlmZddlmZddlmZddlm	Z
ddlmZddlmZe
d�Zee
d	�BZe
d
�ZeeBZee
d�Zee
d�Zee
d
�Be
d�ZeeBZee
d�BZeeBZee
d�ZddhZeeBZdd�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Z Gdd�de�Z!Gdd�de�Z"Gd d!�d!e�Z#Gd"d#�d#e�Z$Gd$d%�d%e�Z%Gd&d'�d'e�Z&Gd(d)�d)e&�Z'Gd*d+�d+e�Z(Gd,d-�d-e�Z)Gd.d/�d/e�Z*Gd0d1�d1e�Z+Gd2d3�d3e�Z,Gd4d5�d5e�Z-Gd6d7�d7e�Z.Gd8d9�d9e�Z/Gd:d;�d;e�Z0Gd<d=�d=e�Z1Gd>d?�d?e�Z2Gd@dA�dAe�Z3GdBdC�dCe�Z4GdDdE�dEe�Z5GdFdG�dGe�Z6GdHdI�dIe�Z7GdJdK�dKe �Z8GdLdM�dMe�Z9GdNdO�dOe�Z:GdPdQ�dQe�Z;GdRdS�dSe�Z<GdTdU�dUe<�Z=GdVdW�dWe�Z>GdXdY�dYe�Z?GdZd[�d[e�Z@Gd\d]�d]e�ZAGd^d_�d_e�ZBGd`da�daeB�ZCGdbdc�dceB�ZDGddde�dee�ZEGdfdg�dge�ZFGdhdi�die�ZGGdjdk�dkeH�ZIGdldm�dmeI�ZJGdndo�doeI�ZKGdpdq�dqeJ�ZLeKddr�ZMeKdsdt�ZNeKdudv�ZOejPdwjQdxjRe���jSZTejPdyjQdxjRe�jUdzd{�jUd|d}���jVZWejPd~�jXZYejPdyjQdxjRe�jUdzd{�jUd|d}���jVZZejPdyjQdxjRe�jUdzd{�jUd|d}���jVZ[ejPdyjQdxjRe�jUdzd{�jUd|d}���jVZ\dd��Z]d�d��Z^d�d��Z_d�d��Z`d�d��Zad�d��Zbd�d��Zcd�d��Zdd�d��Zed�d��Zfd�d��Zgd�d��Zhd�d��Zid�d��Zjd�d��Zkd�d��Zld�d��Zmd�d��Znd�d��Zod�d��Zpd�d��Zqd�d��Zrd�d��Zsd�d��Ztd�d��Zud�d��Zvd�d��Zwd�d��Zxd�d��Zyd�d��Zzd�d��Z{d�d��Z|d�d��Z}d�d„Z~d�dĄZd�dƄZ�d�dȄZ�d�dʄZ�d�d̄Z�d�d΄Z�d�dЄZ�d�d҄Z�d�dԄZ�d�dքZ�d�d؄Z�d�dڄZ�d�d܄Z�d�dބZ�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�dS)��N)�	hexdigits)�OrderedDict)�
itemgetter)�_encoded_words)�errors)�utilsz 	�(z
()<>@,:;.\"[]�.z."(z/?=z*'%�%�
�
cCs dt|�jdd�jdd�dS)N�"�\z\\z\")�str�replace)�value�r�2/usr/lib64/python3.6/email/_header_value_parser.py�quote_stringbsrcs�eZdZdZdZdZ�fdd�Zdd�Z�fdd�Ze	d	d
��Z
e	dd��Zd
d�Ze	dd��Z
e	dd��Zdd�Zddd�Zddd�Zddd�Z�ZS)�	TokenListNTcst�j||�g|_dS)N)�super�__init__�defects)�self�args�kw)�	__class__rrroszTokenList.__init__cCsdjdd�|D��S)N�css|]}t|�VqdS)N)r)�.0�xrrr�	<genexpr>tsz$TokenList.__str__.<locals>.<genexpr>)�join)rrrr�__str__sszTokenList.__str__csdj|jjt�j��S)Nz{}({}))�formatr�__name__r�__repr__)r)rrrr%vs
zTokenList.__repr__cCsdjdd�|D��S)Nrcss|]}|jr|jVqdS)N)r)rrrrrr |sz"TokenList.value.<locals>.<genexpr>)r!)rrrrrzszTokenList.valuecCstdd�|D�|j�S)Ncss|]}|jVqdS)N)�all_defects)rrrrrr �sz(TokenList.all_defects.<locals>.<genexpr>)�sumr)rrrrr&~szTokenList.all_defectscCs|dj�S)Nr)�startswith_fws)rrrrr(�szTokenList.startswith_fwscCstdd�|D��S)Ncss|]}|jVqdS)N)�
as_ew_allowed)r�partrrrr �sz*TokenList.as_ew_allowed.<locals>.<genexpr>)�all)rrrrr)�szTokenList.as_ew_allowedcCs"g}x|D]}|j|j�q
W|S)N)�extend�comments)rr-�tokenrrrr-�s
zTokenList.commentscCst||d�S)N)�policy)�_refold_parse_tree)rr/rrr�fold�szTokenList.foldrcCst|j|d��dS)N)�indent)�print�ppstr)rr2rrr�pprint�szTokenList.pprintcCsdj|j|d��S)Nr)r2)r!�_pp)rr2rrrr4�szTokenList.ppstrccs~dj||jj|j�Vx<|D]4}t|d�s<|dj|�Vq|j|d�EdHqW|jrhdj|j�}nd}dj||�VdS)Nz{}{}/{}(r6z*    !! invalid element in token list: {!r}z    z Defects: {}rz{}){})r#rr$�
token_type�hasattrr6r)rr2r.Zextrarrrr6�s


z
TokenList._pp)r)r)r)r$�
__module__�__qualname__r7�syntactic_break�ew_combine_allowedrr"r%�propertyrr&r(r)r-r1r5r4r6�
__classcell__rr)rrris

rc@s$eZdZedd��Zedd��ZdS)�WhiteSpaceTokenListcCsdS)N� r)rrrrr�szWhiteSpaceTokenList.valuecCsdd�|D�S)NcSsg|]}|jdkr|j�qS)�comment)r7�content)rrrrr�
<listcomp>�sz0WhiteSpaceTokenList.comments.<locals>.<listcomp>r)rrrrr-�szWhiteSpaceTokenList.commentsN)r$r9r:r=rr-rrrrr?�sr?c@seZdZdZdS)�UnstructuredTokenList�unstructuredN)r$r9r:r7rrrrrD�srDc@seZdZdZdS)�Phrase�phraseN)r$r9r:r7rrrrrF�srFc@seZdZdZdS)�WordZwordN)r$r9r:r7rrrrrH�srHc@seZdZdZdS)�CFWSList�cfwsN)r$r9r:r7rrrrrI�srIc@seZdZdZdS)�Atom�atomN)r$r9r:r7rrrrrK�srKc@seZdZdZdZdS)�Tokenr.FN)r$r9r:r7Zencode_as_ewrrrrrM�srMc@seZdZdZdZdZdZdS)�EncodedWordzencoded-wordN)r$r9r:r7�cte�charset�langrrrrrN�srNc@s4eZdZdZedd��Zedd��Zedd��ZdS)	�QuotedStringz
quoted-stringcCs"x|D]}|jdkr|jSqWdS)Nzbare-quoted-string)r7r)rrrrrrB�s

zQuotedString.contentcCsBg}x2|D]*}|jdkr(|jt|��q
|j|j�q
Wdj|�S)Nzbare-quoted-stringr)r7�appendrrr!)r�resrrrr�quoted_value�s

zQuotedString.quoted_valuecCs"x|D]}|jdkr|jSqWdS)Nzbare-quoted-string)r7r)rr.rrr�stripped_value�s

zQuotedString.stripped_valueN)r$r9r:r7r=rBrUrVrrrrrR�s
rRc@s$eZdZdZdd�Zedd��ZdS)�BareQuotedStringzbare-quoted-stringcCstdjdd�|D���S)Nrcss|]}t|�VqdS)N)r)rrrrrr �sz+BareQuotedString.__str__.<locals>.<genexpr>)rr!)rrrrr"�szBareQuotedString.__str__cCsdjdd�|D��S)Nrcss|]}t|�VqdS)N)r)rrrrrr sz)BareQuotedString.value.<locals>.<genexpr>)r!)rrrrr�szBareQuotedString.valueN)r$r9r:r7r"r=rrrrrrW�srWc@s8eZdZdZdd�Zdd�Zedd��Zedd	��Zd
S)�CommentrAcs(djtdg�fdd��D�dggg��S)Nrrcsg|]}�j|��qSr)�quote)rr)rrrrCsz#Comment.__str__.<locals>.<listcomp>�))r!r')rr)rrr"s
zComment.__str__cCs2|jdkrt|�St|�jdd�jdd�jdd�S)NrArz\\rz\(rZz\))r7rr)rrrrrrYs

z
Comment.quotecCsdjdd�|D��S)Nrcss|]}t|�VqdS)N)r)rrrrrr sz"Comment.content.<locals>.<genexpr>)r!)rrrrrBszComment.contentcCs|jgS)N)rB)rrrrr-szComment.commentsN)	r$r9r:r7r"rYr=rBr-rrrrrXs
rXc@s4eZdZdZedd��Zedd��Zedd��ZdS)	�AddressListzaddress-listcCsdd�|D�S)NcSsg|]}|jdkr|�qS)�address)r7)rrrrrrC$sz)AddressList.addresses.<locals>.<listcomp>r)rrrr�	addresses"szAddressList.addressescCstdd�|D�g�S)Ncss|]}|jdkr|jVqdS)r\N)r7�	mailboxes)rrrrrr (sz(AddressList.mailboxes.<locals>.<genexpr>)r')rrrrr^&szAddressList.mailboxescCstdd�|D�g�S)Ncss|]}|jdkr|jVqdS)r\N)r7�
all_mailboxes)rrrrrr -sz,AddressList.all_mailboxes.<locals>.<genexpr>)r')rrrrr_+szAddressList.all_mailboxesN)r$r9r:r7r=r]r^r_rrrrr[sr[c@s4eZdZdZedd��Zedd��Zedd��ZdS)	�Addressr\cCs|djdkr|djSdS)Nr�group)r7�display_name)rrrrrb5szAddress.display_namecCs4|djdkr|dgS|djdkr*gS|djS)Nr�mailboxzinvalid-mailbox)r7r^)rrrrr^:s

zAddress.mailboxescCs:|djdkr|dgS|djdkr0|dgS|djS)Nrrczinvalid-mailbox)r7r_)rrrrr_Bs


zAddress.all_mailboxesN)r$r9r:r7r=rbr^r_rrrrr`1sr`c@s(eZdZdZedd��Zedd��ZdS)�MailboxListzmailbox-listcCsdd�|D�S)NcSsg|]}|jdkr|�qS)rc)r7)rrrrrrCPsz)MailboxList.mailboxes.<locals>.<listcomp>r)rrrrr^NszMailboxList.mailboxescCsdd�|D�S)NcSsg|]}|jdkr|�qS)rc�invalid-mailbox)rcre)r7)rrrrrrCTsz-MailboxList.all_mailboxes.<locals>.<listcomp>r)rrrrr_RszMailboxList.all_mailboxesN)r$r9r:r7r=r^r_rrrrrdJsrdc@s(eZdZdZedd��Zedd��ZdS)�	GroupListz
group-listcCs"|s|djdkrgS|djS)Nrzmailbox-list)r7r^)rrrrr^\szGroupList.mailboxescCs"|s|djdkrgS|djS)Nrzmailbox-list)r7r_)rrrrr_bszGroupList.all_mailboxesN)r$r9r:r7r=r^r_rrrrrfXsrfc@s4eZdZdZedd��Zedd��Zedd��ZdS)	�GroupracCs|djdkrgS|djS)N�z
group-list)r7r^)rrrrr^mszGroup.mailboxescCs|djdkrgS|djS)Nrhz
group-list)r7r_)rrrrr_sszGroup.all_mailboxescCs
|djS)Nr)rb)rrrrrbyszGroup.display_nameN)r$r9r:r7r=r^r_rbrrrrrgisrgc@sLeZdZdZedd��Zedd��Zedd��Zedd	��Zed
d��Z	dS)
�NameAddrz	name-addrcCst|�dkrdS|djS)N�r)�lenrb)rrrrrb�szNameAddr.display_namecCs
|djS)Nrj���)�
local_part)rrrrrm�szNameAddr.local_partcCs
|djS)Nrjrl)�domain)rrrrrn�szNameAddr.domaincCs
|djS)Nrjrl)�route)rrrrro�szNameAddr.routecCs
|djS)Nrjrl)�	addr_spec)rrrrrp�szNameAddr.addr_specN)
r$r9r:r7r=rbrmrnrorprrrrri~sric@s@eZdZdZedd��Zedd��Zedd��Zedd	��Zd
S)�	AngleAddrz
angle-addrcCs"x|D]}|jdkr|jSqWdS)Nz	addr-spec)r7rm)rrrrrrm�s

zAngleAddr.local_partcCs"x|D]}|jdkr|jSqWdS)Nz	addr-spec)r7rn)rrrrrrn�s

zAngleAddr.domaincCs"x|D]}|jdkr|jSqWdS)Nz	obs-route)r7�domains)rrrrrro�s

zAngleAddr.routecCs<x6|D]*}|jdkr|jr |jSt|j�|jSqWdSdS)Nz	addr-specz<>)r7rmrpr)rrrrrrp�s

zAngleAddr.addr_specN)	r$r9r:r7r=rmrnrorprrrrrq�s
rqc@seZdZdZedd��ZdS)�ObsRoutez	obs-routecCsdd�|D�S)NcSsg|]}|jdkr|j�qS)rn)r7rn)rrrrrrC�sz$ObsRoute.domains.<locals>.<listcomp>r)rrrrrr�szObsRoute.domainsN)r$r9r:r7r=rrrrrrrs�srsc@sLeZdZdZedd��Zedd��Zedd��Zedd	��Zed
d��Z	dS)
�MailboxrccCs|djdkr|djSdS)Nrz	name-addr)r7rb)rrrrrb�szMailbox.display_namecCs
|djS)Nr)rm)rrrrrm�szMailbox.local_partcCs
|djS)Nr)rn)rrrrrn�szMailbox.domaincCs|djdkr|djSdS)Nrz	name-addr)r7ro)rrrrro�sz
Mailbox.routecCs
|djS)Nr)rp)rrrrrp�szMailbox.addr_specN)
r$r9r:r7r=rbrmrnrorprrrrrt�srtc@s,eZdZdZedd��ZeZZZZ	dS)�InvalidMailboxzinvalid-mailboxcCsdS)Nr)rrrrrb�szInvalidMailbox.display_nameN)
r$r9r:r7r=rbrmrnrorprrrrru�srucs(eZdZdZdZe�fdd��Z�ZS)�DomainrnFcsdjt�jj��S)Nr)r!rr�split)r)rrrrn�sz
Domain.domain)r$r9r:r7r)r=rnr>rr)rrrv�srvc@seZdZdZdS)�DotAtomzdot-atomN)r$r9r:r7rrrrrx�srxc@seZdZdZdZdS)�DotAtomTextz
dot-atom-textTN)r$r9r:r7r)rrrrry�sryc@sDeZdZdZdZedd��Zedd��Zedd��Zed	d
��Z	dS)�AddrSpecz	addr-specFcCs
|djS)Nr)rm)rrrrrmszAddrSpec.local_partcCst|�dkrdS|djS)N�rjrl)rkrn)rrrrrnszAddrSpec.domaincCs<t|�dkr|djS|djj�|dj|djj�S)Nr{rrjrh)rkr�rstrip�lstrip)rrrrrs
zAddrSpec.valuecCsLt|j�}t|�t|t�kr*t|j�}n|j}|jdk	rH|d|jS|S)N�@)�setrmrk�
DOT_ATOM_ENDSrrn)rZnamesetZlprrrrps

zAddrSpec.addr_specN)
r$r9r:r7r)r=rmrnrrprrrrrz�srzc@seZdZdZdZdS)�ObsLocalPartzobs-local-partFN)r$r9r:r7r)rrrrr� sr�cs4eZdZdZdZedd��Ze�fdd��Z�ZS)�DisplayNamezdisplay-nameFcCs�t|�}|djdkr"|jd�n*|ddjdkrLt|ddd��|d<|djdkrd|j�n*|ddjdkr�t|ddd��|d	<|jS)
NrrJrjrlrlrlrlrlrl)rr7�popr)rrTrrrrb+s
zDisplayName.display_namecs�d}|jrd}nx|D]}|jdkrd}qW|r�d}}|djdksX|ddjdkr\d}|d	jdks||d
djdkr�d}|t|j�|St�jSdS)NFTz
quoted-stringrrrJr@rjrlrlrl)rr7rrbrr)rrYrZpreZpost)rrrr:s

  zDisplayName.value)	r$r9r:r7r<r=rbrr>rr)rrr�&sr�c@s,eZdZdZdZedd��Zedd��ZdS)�	LocalPartz
local-partFcCs&|djdkr|djS|djSdS)Nrz
quoted-string)r7rUr)rrrrrSs
zLocalPart.valuecCs�tg}t}d}x�|dtgD]�}|jdkr.q|r^|jdkr^|djdkr^t|dd��|d<t|t�}|r�|jdkr�|djdkr�|jt|dd���n
|j|�|d	}|}qWt|dd
��}|jS)NFrrJ�dotrjrlrlrlrlrl)�DOTr7r�
isinstancerSr)rrTZlastZ
last_is_tl�tokZis_tlrrrrmZs$


zLocalPart.local_partN)r$r9r:r7r)r=rrmrrrrr�Nsr�cs4eZdZdZdZe�fdd��Zedd��Z�ZS)�
DomainLiteralzdomain-literalFcsdjt�jj��S)Nr)r!rrrw)r)rrrrnwszDomainLiteral.domaincCs"x|D]}|jdkr|jSqWdS)N�ptext)r7r)rrrrr�ip{s

zDomainLiteral.ip)	r$r9r:r7r)r=rnr�r>rr)rrr�rsr�c@seZdZdZdZdZdS)�MIMEVersionzmime-versionN)r$r9r:r7�major�minorrrrrr��sr�c@s4eZdZdZdZdZdZedd��Zedd��Z	dS)	�	Parameter�	parameterFzus-asciicCs|jr|djSdS)Nrjr)�	sectioned�number)rrrr�section_number�szParameter.section_numbercCsbx\|D]T}|jdkr|jS|jdkrx4|D],}|jdkr*x|D]}|jdkr>|jSq>Wq*WqWdS)Nrz
quoted-stringzbare-quoted-stringr)r7rV)rr.rrr�param_value�s






zParameter.param_valueN)
r$r9r:r7r��extendedrPr=r�r�rrrrr��sr�c@seZdZdZdS)�InvalidParameterzinvalid-parameterN)r$r9r:r7rrrrr��sr�c@seZdZdZedd��ZdS)�	Attribute�	attributecCs$x|D]}|jjd�r|jSqWdS)N�attrtext)r7�endswithr)rr.rrrrV�s
zAttribute.stripped_valueN)r$r9r:r7r=rVrrrrr��sr�c@seZdZdZdZdS)�Section�sectionN)r$r9r:r7r�rrrrr��sr�c@seZdZdZedd��ZdS)�ValuercCs2|d}|jdkr|d}|jjd�r,|jS|jS)NrrJrj�
quoted-stringr��extended-attribute)r�r�r�)r7r�rVr)rr.rrrrV�s
zValue.stripped_valueN)r$r9r:r7r=rVrrrrr��sr�c@s(eZdZdZdZedd��Zdd�ZdS)�MimeParameterszmime-parametersFccs�t�}x\|D]T}|jjd�sq|djdkr.q|djj�}||krLg||<||j|j|f�qW�x�|j�D�]�\}}t|t	d�d�}|dd}|j
}|jr�t|�dkr�|dddkr�|ddj
jtjd��|dd�}g}d}x�|D]�\}	}
|	|k�r6|
j�s$|
j
jtjd��q�n|
j
jtjd��|d7}|
j}|
j�r�ytjj|�}Wn&tk
�r�tjj|d	d
�}YnRXy|j|d�}Wn"tk
�r�|jdd�}YnXtj|��r�|
j
jtj��|j|�q�Wd
j|�}||fVqpWdS)Nr�rr�)�keyrjz.duplicate parameter name; duplicate(s) ignoredz+duplicate parameter name; duplicate ignoredz(inconsistent RFC2231 parameter numberingzlatin-1)�encoding�surrogateescapezus-asciir)rr7r�r�striprSr��items�sortedrrPr�rkrr�InvalidHeaderDefectr��urllib�parseZunquote_to_bytes�UnicodeEncodeErrorZunquote�decode�LookupErrorr�_has_surrogates�UndecodableBytesDefectr!)r�paramsr.�name�partsZfirst_paramrPZvalue_parts�ir��paramrrrrr��sZ




zMimeParameters.paramscCsXg}x8|jD].\}}|r0|jdj|t|���q|j|�qWdj|�}|rTd|SdS)Nz{}={}z; r@r)r�rSr#rr!)rr�r�rrrrr"s
zMimeParameters.__str__N)r$r9r:r7r;r=r�r"rrrrr��sFr�c@seZdZdZedd��ZdS)�ParameterizedHeaderValueFcCs&x t|�D]}|jdkr
|jSq
WiS)Nzmime-parameters)�reversedr7r�)rr.rrrr�%s

zParameterizedHeaderValue.paramsN)r$r9r:r;r=r�rrrrr�sr�c@seZdZdZdZdZdZdS)�ContentTypezcontent-typeF�textZplainN)r$r9r:r7r)�maintype�subtyperrrrr�-sr�c@seZdZdZdZdZdS)�ContentDispositionzcontent-dispositionFN)r$r9r:r7r)�content_dispositionrrrrr�5sr�c@seZdZdZdZdZdS)�ContentTransferEncodingzcontent-transfer-encodingFZ7bitN)r$r9r:r7r)rOrrrrr�<sr�c@seZdZdZdZdS)�HeaderLabelzheader-labelFN)r$r9r:r7r)rrrrr�Csr�c@seZdZdZdS)�Header�headerN)r$r9r:r7rrrrr�Isr�csreZdZdZdZdZ�fdd�Z�fdd�Zdd�Ze	dd	��Z
d�fdd�	Zd
d�Ze	dd��Z
dd�Z�ZS)�TerminalTcst�j||�}||_g|_|S)N)r�__new__r7r)�clsrr7r)rrrr�XszTerminal.__new__csdj|jjt�j��S)Nz{}({}))r#rr$rr%)r)rrrr%^szTerminal.__repr__cCst|jjd|j�dS)N�/)r3rr$r7)rrrrr5aszTerminal.pprintcCs
t|j�S)N)�listr)rrrrr&dszTerminal.all_defectsrcs2dj||jj|jt�j�|js"dn
dj|j��gS)Nz
{}{}/{}({}){}rz {})r#rr$r7rr%r)rr2)rrrr6hszTerminal._ppcCsdS)Nr)rrrr�pop_trailing_wsqszTerminal.pop_trailing_wscCsgS)Nr)rrrrr-uszTerminal.commentscCst|�|jfS)N)rr7)rrrr�__getnewargs__yszTerminal.__getnewargs__)r)r$r9r:r)r<r;r�r%r5r=r&r6r�r-r�r>rr)rrr�Rs	r�c@s eZdZedd��Zdd�ZdS)�WhiteSpaceTerminalcCsdS)Nr@r)rrrrrszWhiteSpaceTerminal.valuecCsdS)NTr)rrrrr(�sz!WhiteSpaceTerminal.startswith_fwsN)r$r9r:r=rr(rrrrr�}sr�c@s eZdZedd��Zdd�ZdS)�
ValueTerminalcCs|S)Nr)rrrrr�szValueTerminal.valuecCsdS)NFr)rrrrr(�szValueTerminal.startswith_fwsN)r$r9r:r=rr(rrrrr��sr�c@s eZdZedd��Zdd�ZdS)�EWWhiteSpaceTerminalcCsdS)Nrr)rrrrr�szEWWhiteSpaceTerminal.valuecCsdS)Nrr)rrrrr"�szEWWhiteSpaceTerminal.__str__N)r$r9r:r=rr"rrrrr��sr�r��,zlist-separatorr~zroute-component-markerz([{}]+)rz[^{}]+rz\\�]z\]z[\x00-\x20\x7F]cCs>t|�}|r|jjtj|��tj|�r:|jjtjd��dS)Nz*Non-ASCII characters found in header token)�_non_printable_finderrrSrZNonPrintableDefectrr�r�)�xtextZnon_printablesrrr�_validate_xtext�s

r�cCs�t|d�^}}g}d}d}xbtt|��D]J}||dkrL|rFd}d}nd}q(|rVd}n|||krdP|j||�q(W|d}dj|�dj||d�g|�|fS)NrjFrTr)�
_wsp_splitter�rangerkrSr!)r�endcharsZfragment�	remainderZvchars�escape�had_qp�posrrr�_get_ptext_to_endchars�s$	r�cCs.|j�}t|dt|�t|��d�}||fS)N�fws)r}r�rk)rZnewvaluer�rrr�get_fws�sr�c
Cs�t�}|jd�s tjdj|���|dd�jdd�^}}||dd�krXtjdj|���dj|�}t|�dkr�|dtkr�|dtkr�|jdd�^}}|d|}t|j��dkr�|j	j
tjd��||_dj|�}yt
jd|d�\}}}}	Wn(tk
�rtjd	j|j���YnX||_||_|j	j|	�xh|�r�|dtk�rdt|�\}
}|j
|
��q6t|d�^}}t|d
�}t|�|j
|�dj|�}�q6W||fS)Nz=?z"expected encoded word but found {}rhz?=rjrrzwhitespace inside encoded wordz!encoded word format invalid: '{}'�vtext)rN�
startswithr�HeaderParseErrorr#rwr!rkrrrSr�rO�_ewr��
ValueErrorrPrQr,�WSPr�r�r�r�)
r�ewr�r�Zremstr�restr�rPrQrr.�charsr�rrr�get_encoded_word�sH

$




r�cCst�}�x|�r|dtkr4t|�\}}|j|�q
|jd�r�yt|�\}}Wntjk
rdYnrXd}t|�dkr�|dj	dkr�|j
jtjd��d}|r�t|�dkr�|d
j	d	kr�t|dd�|d<|j|�q
t
|d�^}}t|d
�}t|�|j|�dj|�}q
W|S)Nrz=?Trjr�z&missing whitespace before encoded wordFrhzencoded-wordr�rrl���rlrl)rDr�r�rSr�r�rr�rkr7rr�r�r�r�r�r!)rrEr.Zhave_wsr�r�r�rrr�get_unstructured!s:






r�cCs*t|d�\}}}t|d�}t|�||fS)Nz()r�)r�r�r�)rr��_rrr�get_qp_ctextYs
r�cCs*t|d�\}}}t|d�}t|�||fS)Nr
r�)r�r�r�)rr�r�rrr�get_qcontentjs

r�cCsNt|�}|stjdj|���|j�}|t|�d�}t|d�}t|�||fS)Nzexpected atext but found '{}'�atext)�_non_atom_end_matcherrr�r#rarkr�r�)r�mr�rrr�	get_atextys
r�cCs|ddkrtjdj|���t�}|dd�}|ddkrPt|�\}}|j|�x�|r�|ddkr�|dtkr|t|�\}}nd|dd�dkr�y"t|�\}}|j	jtj
d��Wq�tjk
r�t|�\}}Yq�Xnt|�\}}|j|�qRW|�s|j	jtj
d��||fS||dd�fS)	Nrr
zexpected '"' but found '{}'rjrhz=?z!encoded word inside quoted stringz"end of header inside quoted string)rr�r#rWr�rSr�r�r�rr�)rZbare_quoted_stringr.rrr�get_bare_quoted_string�s2


r�cCs�|r |ddkr tjdj|���t�}|dd�}x^|r�|ddkr�|dtkr^t|�\}}n&|ddkrxt|�\}}nt|�\}}|j|�q4W|s�|j	jtj
d��||fS||dd�fS)Nrrzexpected '(' but found '{}'rjrZzend of header inside comment)rr�r#rXr�r��get_commentr�rSrr�)rrAr.rrrr��s"
r�cCsTt�}xD|rJ|dtkrJ|dtkr2t|�\}}nt|�\}}|j|�qW||fS)Nr)rI�CFWS_LEADERr�r�r�rS)rrJr.rrr�get_cfws�sr�cCspt�}|r,|dtkr,t|�\}}|j|�t|�\}}|j|�|rh|dtkrht|�\}}|j|�||fS)Nr)rRr�r�rSr�)rZ
quoted_stringr.rrr�get_quoted_string�s


r�cCs�t�}|r,|dtkr,t|�\}}|j|�|rL|dtkrLtjdj|���|jd�r�yt	|�\}}Wq�tjk
r�t
|�\}}Yq�Xnt
|�\}}|j|�|r�|dtkr�t|�\}}|j|�||fS)Nrzexpected atom but found '{}'z=?)rKr�r�rS�	ATOM_ENDSrr�r#r�r�r�)rrLr.rrr�get_atom�s$



r�cCs�t�}|s|dtkr(tjdj|���xP|rx|dtkrxt|�\}}|j|�|r*|ddkr*|jt�|dd�}q*W|dtkr�tjdjd|���||fS)Nrz8expected atom at a start of dot-atom-text but found '{}'r	rjz4expected atom at end of dot-atom-text but found '{}'rl)ryr�rr�r#r�rSr�)rZ
dot_atom_textr.rrr�get_dot_atom_text�s

r�cCs�t�}|dtkr(t|�\}}|j|�|jd�rhyt|�\}}Wqttjk
rdt|�\}}YqtXnt|�\}}|j|�|r�|dtkr�t|�\}}|j|�||fS)Nrz=?)	rxr�r�rSr�r�rr�r�)rZdot_atomr.rrr�get_dot_atoms



r�cCs�|dtkrt|�\}}nd}|ddkr8t|�\}}n*|dtkrVtjdj|���nt|�\}}|dk	rx|g|dd�<||fS)Nrr
z1Expected 'atom' or 'quoted-string' but found '{}')r�r�r��SPECIALSrr�r#r�)r�leaderr.rrr�get_word*s
r�cCs�t�}yt|�\}}|j|�Wn(tjk
rH|jjtjd��YnXx�|r�|dtkr�|ddkr�|jt�|jjtj	d��|dd�}qLyt|�\}}WnDtjk
r�|dt
kr�t|�\}}|jjtj	d��n�YnX|j|�qLW||fS)Nzphrase does not start with wordrr	zperiod in 'phrase'rjzcomment found without atom)rFr�rSrr�rr��PHRASE_ENDSr��ObsoleteHeaderDefectr�r�)rrGr.rrr�
get_phraseIs.




r�cCstt�}d}|dtkr"t|�\}}|s6tjdj|���yt|�\}}Wn^tjk
r�yt|�\}}Wn6tjk
r�|ddkr�|dtkr��t	�}YnXYnX|dk	r�|g|dd�<|j
|�|o�|ddks�|dtk�r2tt|�|�\}}|j
dk�r|jj
tjd��n|jj
tjd��||d<y|jjd�Wn(tk
�rj|jj
tjd��YnX||fS)	Nrz"expected local-part but found '{}'rzinvalid-obs-local-partz<local-part is not dot-atom, quoted-string, or obs-local-partz,local-part is not a dot-atom (contains CFWS)�asciiz)local-part contains non-ASCII characters))r�r�r�rr�r#r�r�r�rrS�get_obs_local_partrr7rr�r�r�encoder�ZNonASCIILocalPartDefect)rrmr�r.�obs_local_partrrr�get_local_partosB




r�cCs�t�}d}�x|o(|ddks,|dtk�r*|ddkrl|rN|jjtjd��|jt�d}|dd�}qnD|ddkr�|jt|dd��|dd�}|jjtjd	��d}q|r�|djd
kr�|jjtjd��yt	|�\}}d}Wn4tj
k
�r|dtk�r�t|�\}}YnX|j|�qW|djd
k�s\|djdk�rn|djd
k�rn|jjtjd
��|djd
k�s�|djdk�r�|djd
k�r�|jjtjd��|j�r�d|_||fS)NFrrr	zinvalid repeated '.'Trjzmisplaced-specialz/'\' character outside of quoted-string/ccontentr�zmissing '.' between wordsrJz!Invalid leading '.' in local partrhz"Invalid trailing '.' in local partzinvalid-obs-local-partrlrlrlr�)
r�r�rrSrr�r�r�r7r�r�r�r�)rr�Zlast_non_ws_was_dotr.rrrr��sV"





r�cCs@t|d�\}}}t|d�}|r0|jjtjd��t|�||fS)Nz[]r�z(quoted printable found in domain-literal)r�r�rrSrr�r�)rr�r�rrr�	get_dtext�s

rcCs,|rdS|jtjd��|jtdd��dS)NFz"end of input inside domain-literalr�zdomain-literal-endT)rSrr�r�)r�domain_literalrrr�_check_for_early_dl_end�srcCslt�}|dtkr(t|�\}}|j|�|s6tjd��|ddkrRtjdj|���|dd�}t||�rp||fS|jtdd��|dt	kr�t
|�\}}|j|�t|�\}}|j|�t||�r�||fS|dt	kr�t
|�\}}|j|�t||��r||fS|ddk�rtjdj|���|jtdd	��|dd�}|�rd|dtk�rdt|�\}}|j|�||fS)
Nrzexpected domain-literal�[z6expected '[' at start of domain-literal but found '{}'rjzdomain-literal-startr�z4expected ']' at end of domain-literal but found '{}'zdomain-literal-end)r�r�r�rSrr�r#rr�r�r�r)rrr.rrr�get_domain_literal�sD







rcCstt�}d}|dtkr"t|�\}}|s6tjdj|���|ddkrvt|�\}}|dk	rd|g|dd�<|j|�||fSyt|�\}}Wn"tjk
r�t	|�\}}YnX|r�|ddkr�tjd��|dk	r�|g|dd�<|j|�|o�|ddk�rl|j
jtjd��|djdk�r(|d|dd�<xB|�rj|ddk�rj|jt
�t	|d	d��\}}|j|��q*W||fS)
Nrzexpected domain but found '{}'rr~zInvalid Domainr	z(domain is not a dot-atom (contains CFWS)zdot-atomrj)rvr�r�rr�r#rrSr�r�rr�r7r�)rrnr�r.rrr�
get_domains@




rcCs~t�}t|�\}}|j|�|s.|ddkrH|jjtjd��||fS|jtdd��t|dd��\}}|j|�||fS)Nrr~z"add-spec local part with no domainzaddress-at-symbolrj)rzr�rSrrr�r�r)rrpr.rrr�
get_addr_spec.s


rcCs�t�}xf|rl|ddks$|dtkrl|dtkrHt|�\}}|j|�q|ddkr|jt�|dd�}qW|s�|ddkr�tjdj|���|jt�t	|dd��\}}|j|�x�|o�|ddk�rB|jt�|dd�}|s�P|dtk�rt|�\}}|j|�|ddkr�|jt�t	|dd��\}}|j|�q�W|�sTtjd��|ddk�rrtjdj|���|jt
dd	��||dd�fS)
Nrr�rjr~z(expected obs-route domain but found '{}'z%end of header while parsing obs-route�:z4expected ':' marking end of obs-route but found '{}'zend-of-obs-route-marker)rsr�r�rS�
ListSeparatorrr�r#�RouteComponentMarkerrr�)rZ	obs_router.rrr�
get_obs_route>sB






r
cCs�t�}|dtkr(t|�\}}|j|�|s:|ddkrJtjdj|���|jtdd��|dd�}|ddkr�|jtdd��|jjtj	d��|dd�}||fSyt
|�\}}Wnztjk
�r2y"t|�\}}|jjtjd	��Wn(tjk
�rtjd
j|���YnX|j|�t
|�\}}YnX|j|�|�r`|ddk�r`|dd�}n|jjtj	d��|jtdd��|�r�|dtk�r�t|�\}}|j|�||fS)Nr�<z"expected angle-addr but found '{}'zangle-addr-startrj�>zangle-addr-endznull addr-spec in angle-addrz*obsolete route specification in angle-addrz.expected addr-spec or obs-route but found '{}'z"missing trailing '>' on angle-addr)
rqr�r�rSrr�r#r�rr�rr
r�)rZ
angle_addrr.rrr�get_angle_addrgsJ






r
cCs<t�}t|�\}}|j|dd��|jdd�|_||fS)N)r�r�r,r)rrbr.rrr�get_display_name�s
rcCs�t�}d}|dtkr6t|�\}}|s6tjdj|���|ddkr�|dtkr^tjdj|���t|�\}}|s~tjdj|���|dk	r�|g|ddd�<d}|j|�t	|�\}}|dk	r�|g|dd�<|j|�||fS)Nrz!expected name-addr but found '{}'r)
rir�r�rr�r#r�rrSr
)rZ	name_addrr�r.rrr�
get_name_addr�s0

rcCs�t�}yt|�\}}WnNtjk
rdyt|�\}}Wn&tjk
r^tjdj|���YnXYnXtdd�|jD��r�d|_|j	|�||fS)Nzexpected mailbox but found '{}'css|]}t|tj�VqdS)N)r�rr�)rrrrrr �szget_mailbox.<locals>.<genexpr>zinvalid-mailbox)
rtrrr�rr#�anyr&r7rS)rrcr.rrr�get_mailbox�s
rcCsht�}xX|r^|d|kr^|dtkrF|jt|dd��|dd�}qt|�\}}|j|�qW||fS)Nrzmisplaced-specialrj)rur�rSr�r�)rr�Zinvalid_mailboxr.rrr�get_invalid_mailbox�srcCs�t�}�x�|o|ddk�r�yt|�\}}|j|�W�ntjk
�r@d}|dtkr�t|�\}}|sz|ddkr�|j|�|jjtjd��n@t	|d�\}}|dk	r�|g|dd�<|j|�|jjtj
d��nb|ddkr�|jjtjd��nBt	|d�\}}|dk	�r |g|dd�<|j|�|jjtj
d��YnX|�r�|ddk�r�|d	}d|_t	|d�\}}|j|�|jjtj
d��|r
|ddkr
|jt
�|dd�}q
W||fS)
Nr�;z,;zempty element in mailbox-listzinvalid mailbox in mailbox-listr�rjzinvalid-mailboxrl)rdrrSrr�r�r�rr�rr�r7r,r)rZmailbox_listr.r�rcrrr�get_mailbox_list�sN













rcCst�}|s$|jjtjd��||fSd}|r�|dtkr�t|�\}}|sl|jjtjd��|j|�||fS|ddkr�|j|�||fSt|�\}}t|j	�dkr�|dk	r�|j|�|j
|�|jjtjd��||fS|dk	r�|g|dd�<|j|�||fS)Nzend of header before group-listrzend of header in group-listrzgroup-list with empty entries)rfrrSrr�r�r�rrkr_r,r�)rZ
group_listr�r.rrr�get_group_list"s8







rcCs"t�}t|�\}}|s$|ddkr4tjdj|���|j|�|jtdd��|dd�}|r�|ddkr�|jtdd��||dd�fSt|�\}}|j|�|s�|jjtj	d��n|ddkr�tjd	j|���|jtdd��|dd�}|�r|dt
k�rt|�\}}|j|�||fS)
Nrrz8expected ':' at end of group display name but found '{}'zgroup-display-name-terminatorrjrzgroup-terminatorzend of header in groupz)expected ';' at end of group but found {})rgrrr�r#rSr�rrr�r�r�)rrar.rrr�	get_groupGs2




rcCsxt�}yt|�\}}WnNtjk
rdyt|�\}}Wn&tjk
r^tjdj|���YnXYnX|j|�||fS)Nzexpected address but found '{}')r`rrr�rr#rS)rr\r.rrr�get_addresses
rcCs�t�}�x�|�r�yt|�\}}|j|�W�n$tjk
�rP}�zd}|dtkr�t|�\}}|sr|ddkr�|j|�|jjtjd��nFt	|d�\}}|dk	r�|g|dd�<|jt
|g��|jjtjd��nh|ddkr�|jjtjd��nHt	|d�\}}|dk	�r|g|dd�<|jt
|g��|jjtjd��WYdd}~XnX|�r�|ddk�r�|d	d}d|_t	|d�\}}|j
|�|jjtjd��|r
|jtdd��|dd�}q
W||fS)
Nrr�z"address-list entry with no contentzinvalid address in address-listzempty element in address-listrjzinvalid-mailboxzlist-separatorrl)r[rrSrr�r�r�rr�rr`r�r7r,r�)rZaddress_listr.�errr�rcrrr�get_address_list�sN












rcCs�t�}|s |jjtjd��|S|dtkrXt|�\}}|j|�|sX|jjtjd��d}x8|r�|ddkr�|dtkr�||d7}|dd�}q^W|j�s�|jjtjdj	|���|jt
|d��nt|�|_|jt
|d	��|o�|dtk�r
t|�\}}|j|�|�s |ddk�rX|jdk	�r>|jjtjd
��|�rT|jt
|d��|S|jt
dd��|dd�}|�r�|dtk�r�t|�\}}|j|�|�s�|jdk	�r�|jjtjd
��|Sd}x2|�r�|dtk�r�||d7}|dd�}�q�W|j��s2|jjtjdj	|���|jt
|d��nt|�|_
|jt
|d	��|�rv|dtk�rvt|�\}}|j|�|�r�|jjtjd
��|jt
|d��|S)Nz%Missing MIME version number (eg: 1.0)rz0Expected MIME version number but found only CFWSrr	rjz1Expected MIME major version number but found {!r}r��digitsz0Incomplete MIME version; found only major numberzversion-separatorz1Expected MIME minor version number but found {!r}z'Excess non-CFWS text after MIME version)r�rrSr�HeaderMissingRequiredValuer�r��isdigitr�r#r��intr�r�)rZmime_versionr.rrrr�parse_mime_version�sv













rcCsht�}xX|r^|ddkr^|dtkrF|jt|dd��|dd�}qt|�\}}|j|�qW||fS)Nrrzmisplaced-specialrj)r�r�rSr�r�)rZinvalid_parameterr.rrr�get_invalid_parametersrcCsNt|�}|stjdj|���|j�}|t|�d�}t|d�}t|�||fS)Nzexpected ttext but found '{}'�ttext)�_non_token_end_matcherrr�r#rarkr�r�)rr�r rrr�	get_ttexts	
r"cCs�t�}|r,|dtkr,t|�\}}|j|�|rL|dtkrLtjdj|���t|�\}}|j|�|r�|dtkr�t|�\}}|j|�||fS)Nrzexpected token but found '{}')	rMr�r�rS�
TOKEN_ENDSrr�r#r")rZmtokenr.rrr�	get_token)s	


r$cCsNt|�}|stjdj|���|j�}|t|�d�}t|d�}t|�||fS)Nz expected attrtext but found {!r}r�)�_non_attribute_end_matcherrr�r#rarkr�r�)rr�r�rrr�get_attrtext@s	
r&cCs�t�}|r,|dtkr,t|�\}}|j|�|rL|dtkrLtjdj|���t|�\}}|j|�|r�|dtkr�t|�\}}|j|�||fS)Nrzexpected token but found '{}')	r�r�r�rS�ATTRIBUTE_ENDSrr�r#r&)rr�r.rrr�
get_attributeSs	


r(cCsNt|�}|stjdj|���|j�}|t|�d�}t|d�}t|�||fS)Nz)expected extended attrtext but found {!r}zextended-attrtext)�#_non_extended_attribute_end_matcherrr�r#rarkr�r�)rr�r�rrr�get_extended_attrtextjs
r*cCs�t�}|r,|dtkr,t|�\}}|j|�|rL|dtkrLtjdj|���t|�\}}|j|�|r�|dtkr�t|�\}}|j|�||fS)Nrzexpected token but found '{}')	r�r�r�rS�EXTENDED_ATTRIBUTE_ENDSrr�r#r*)rr�r.rrr�get_extended_attribute|s


r,cCs�t�}|s|ddkr(tjdj|���|jtdd��|dd�}|sX|dj�rhtjdj|���d}x,|r�|dj�r�||d7}|dd�}qnW|ddkr�|dkr�|jjtjd	��t	|�|_
|jt|d
��||fS)Nr�*zExpected section but found {}zsection-markerrjz$Expected section number but found {}r�0z'section number has an invalid leading 0r)r�rr�r#rSr�rrZInvalidHeaderErrorrr�)rr�rrrr�get_section�s&	

r/cCs�t�}|stjd��d}|dtkr0t|�\}}|sDtjdj|���|ddkr^t|�\}}nt|�\}}|dk	r�|g|dd�<|j|�||fS)Nz&Expected value but found end of stringrz Expected value but found only {}r
)	r�rr�r�r�r#r�r,rS)r�vr�r.rrr�	get_value�s 

r1cCsvt�}t|�\}}|j|�|s.|ddkrN|jjtjdj|���||fS|ddkr�y t|�\}}d|_|j|�Wntj	k
r�YnX|s�tj	d��|ddkr�|jt
dd��|dd�}d|_|dd	kr�tj	d
��|jt
d	d��|dd�}d}|�r.|dtk�r.t
|�\}}|j|�d}|}|j�rH|�rH|ddk�rHt|�\}}|j}d
}|jdk�r�|�r�|ddk�r�d}n$t|�\}}	|	�r�|	ddk�r�d}n(yt|�\}}	WnYnX|	�s�d}|�r2|jjtjd��|j|�x,|D]$}
|
jdk�rg|
dd�<|
}P�qW|}nd}|jjtjd��|�rb|ddk�rbd}nt|�\}}|j�s�|jdk�r�|�s�|ddk�r�|j|�|dk	�r�|}||fS|jjtjd��|�s|jjtjd��|j|�|dk�r�||fSn�|dk	�rFx|D]}
|
jdk�rP�qW|
jdk|j|
�|
j|_|ddk�rdtj	dj|���|jt
dd��|dd�}|�r�|ddk�r�t|�\}}|j|�|j|_|�s�|ddk�r�tj	dj|���|jt
dd��|dd�}|dk	�rJt�}x>|�rB|dtk�r(t|�\}}nt|�\}}|j|��qW|}nt|�\}}|j|�|dk	�rn|}||fS)Nrrz)Parameter contains name ({}) but no valuer-TzIncomplete parameterzextended-parameter-markerrj�=zParameter not followed by '='zparameter-separatorr
F�'z5Quoted string value for extended parameter is invalidzbare-quoted-stringzZParameter marked as extended but appears to have a quoted string value that is non-encodedzcApparent initial-extended-value but attribute was not marked as extended or was not initial sectionz(Missing required charset/lang delimiterszextended-attrtextr�z=Expected RFC2231 char/lang encoding delimiter, but found {!r}zRFC2231-delimiterz;Expected RFC2231 char/lang encoding delimiter, but found {})r�r(rSrrr�r#r/r�r�r�r�r�r�r�rVr�r&r*r7r1rrPrQr�r�r�r�)rr�r.r�r�ZappendtoZqstringZinner_valueZ
semi_validr��tr0rrr�
get_parameter�s�























r5cCsht�}�xZ|�rbyt|�\}}|j|�Wn�tjk
r�}z�d}|dtkrZt|�\}}|sl|j|�|S|ddkr�|dk	r�|j|�|jjtjd��n@t	|�\}}|r�|g|dd�<|j|�|jjtjdj
|���WYdd}~XnX|�r@|ddk�r@|d	}d|_t	|�\}}|j|�|jjtjdj
|���|r
|jt
dd��|dd�}q
W|S)
Nrrzparameter entry with no contentzinvalid parameter {!r}rjzinvalid-parameterz)parameter with invalid trailing text {!r}zparameter-separatorrl)r�r5rSrr�r�r�rr�rr#r7r,r�)rZmime_parametersr.rr�r�rrr�parse_mime_parametersQ	sD







 

r6cCs�xX|rX|ddkrX|dtkr@|jt|dd��|dd�}qt|�\}}|j|�qW|sbdS|jtdd��|jt|dd���dS)Nrrzmisplaced-specialrjzparameter-separator)r�rSr�r�r6)Z	tokenlistrr.rrr�_find_mime_parameters�	sr7cCs�t�}d}|s$|jjtjd��|Syt|�\}}Wn8tjk
rl|jjtjdj|���t	||�|SX|j|�|s�|ddkr�|jjtjd��|r�t	||�|S|j
j�j�|_
|jtdd��|dd�}yt|�\}}Wn:tjk
�r$|jjtjd	j|���t	||�|SX|j|�|j
j�j�|_|�sJ|S|dd
k�r�|jjtjdj|���|`
|`t	||�|S|jtd
d��|jt|dd���|S)
NFz"Missing content type specificationz(Expected content maintype but found {!r}rr�zInvalid content typezcontent-type-separatorrjz'Expected content subtype but found {!r}rz<Only parameters are valid after content type, but found {!r}zparameter-separator)r�rrSrrr$r�r�r#r7rr��lowerr�r�r�r6)rZctypeZrecoverr.rrr�parse_content_type_header�	sX











r9c
Cs�t�}|s |jjtjd��|Syt|�\}}Wn8tjk
rh|jjtjdj|���t	||�|SX|j|�|j
j�j�|_
|s�|S|ddkr�|jjtjdj|���t	||�|S|jtdd��|jt|dd���|S)NzMissing content dispositionz+Expected content disposition but found {!r}rrzCOnly parameters are valid after content disposition, but found {!r}zparameter-separatorrj)r�rrSrrr$r�r�r#r7rr�r8r�r�r6)rZdisp_headerr.rrr� parse_content_disposition_header�	s2






r:cCs�t�}|s |jjtjd��|Syt|�\}}Wn.tjk
r^|jjtjdj|���YnX|j|�|j	j
�j�|_|s�|Sx^|r�|jjtjd��|dt
kr�|jt|dd��|dd�}q�t|�\}}|j|�q�W|S)Nz!Missing content transfer encodingz1Expected content transfer encoding but found {!r}z*Extra text after content transfer encodingrzmisplaced-specialrj)r�rrSrrr$r�r�r#rr�r8rOr�r�r�)rZ
cte_headerr.rrr�&parse_content_transfer_encoding_header�	s.



r;cCsDd}|r@|dr@|ddtkr@|dd}|ddd	�|d
<|S)Nrrjrlrlrlrlrlrlrlrl)r�)�linesZwsprrr�_steal_trailing_WSP_if_exists
s
r=cCs�|jptd�}|jrdnd}dg}d}d}d}tdd�}t|�}	�xr|	�r�|	jd�}
|
|krf|d8}qDt|
�}|s�|
jd	kr�tj	|�}nt
j	|�}y|j|�|}Wn6tk
r�t
d
d�|
jD��r�d}nd}d
}YnX|
jdkr�t|
|||�qD|�r�|�r�|
j�s~d}d}|
j�r~|
j|d�dd�}
|j|
k�r~t|
�|t|d�k�rlt|�}|j|�|d|
7<qDt|
d��s�t|
�|	}	nt|||||
j|�}d}qDt|�|t|d�k�r�|d|7<qD|
j�r t|�d|k�r t|�}|�s|
j��r |j||�qDt|
d��sXt|
�}|
j�sN|d7}|j|�||	}	qD|
j�rz|�rz|	jd|
�d
}qDt|�}|�s�|
j��r�|j||�qD|d|7<qDW|jj|�|jS)Nz+infzutf-8zus-asciirrF�wrap_as_ew_blockedrjr�css|]}t|tj�VqdS)N)r�rr�)rrrrrr @
sz%_refold_parse_tree.<locals>.<genexpr>zunknown-8bitTzmime-parameters)r/r�rlrlrlrlrlrl)Zmax_line_length�float�utf8r�r�r�rr7�
SPECIALSNL�
isdisjoint�NLSETr�r�rr&�_fold_mime_parametersr)r;r1�lineseprkr=rSr8�_fold_as_ewr<r(�insertr!)Z
parse_treer/�maxlenr�r<�last_ewr>Z
want_encodingZend_ew_not_allowedr�r*�tstrrPZencoded_part�newlineZnewpartsrrrr0"
s�










r0cCs�|dk	r<|r<tt|d	|d�|��}|d
d|�|d<|dtkr�|d}|dd�}t|d�|krz|jt|��|d
|7<d}|dtkr�|d}|dd�}|dkr�t|d�n|}x�|�r�|t|d�}	|dkr�dn|}
|	t|
�d}|dk�r|jd�q�|d|�}tj||
d�}
t|
�|	}|dk�r\|d|�}tj|�}
|d|
7<|t|�d�}|r�|jd�t|d�}q�W|d|7<|�r�|SdS)Nrjrrzus-asciizutf-8�r@)rPrlrlrlrlrlrlrlrlrlrlrlrlrl)rr�r�rkrSr=r�r�)Z	to_encoder<rHrIr<rPZleading_wspZtrailing_wspZnew_last_ewZremaining_spaceZ	encode_asZ
text_spaceZ
first_partr�ZexcessrrrrF�
sF




rFcCs��x�|jD�]�\}}|dj�jd�s6|dd7<|}d}y|j|�d}Wn0tk
r�d}tj|�rxd}d}nd}YnX|r�tjj	|d	|d
�}	dj
|||	�}
ndj
|t|��}
t|d�t|
�d|kr�|dd
|
|d<q
n"t|
�d|k�r|j
d
|
�q
d}|d}x�|�r�t|�tt|��dt|�}
||
dk�rTd}||
d}}x<|d|�}tjj	|d	|d
�}	t|	�|k�r�P|d8}�qfW|j
dj
||||	��d	}|d7}||d�}|�r|dd7<�qWq
WdS)Nrjr�strictFTzunknown-8bitr�zutf-8r)Zsaferz
{}*={}''{}z{}={}r@rhrz''r{�Nz {}*{}*={}{}rlrlrlrlrlrl)r�r|r�r�r�rr�r�r�rYr#rrkrSr)r*r<rHr�r�rrPZ
error_handlerZencoding_requiredZ
encoded_valuerJr�Zextra_chromeZ
chrome_lenZ
splitpointZmaxchars�partialrrrrD�
s\


 rD)��rer��stringr�collectionsr�operatorrZemailrr�rrrr�r�r�r�r�r�Z	TSPECIALSr#Z	ASPECIALSr'r+rCrArr�rr?rDrFrHrIrKrMrNrRrWrXr[r`rdrfrgrirqrsrtrurvrxryrzr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�r�r�r�rr	�compiler#r!rwr�r�matchr��findallr�r!r%r)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr
r
rrrrrrrrrrrr"r$r&r(r*r,r/r1r5r6r7r9r:r;r=r0rFrDrrrr�<module>FsC"	
!($
V	+




   

*8"
&'/'&).9%>D49/j7

Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 1.63 KB 0644
__init__.cpython-36.opt-2.pyc File 1.04 KB 0644
__init__.cpython-36.pyc File 1.63 KB 0644
_encoded_words.cpython-36.opt-1.pyc File 5.46 KB 0644
_encoded_words.cpython-36.opt-2.pyc File 3.61 KB 0644
_encoded_words.cpython-36.pyc File 5.46 KB 0644
_header_value_parser.cpython-36.opt-1.pyc File 74.33 KB 0644
_header_value_parser.cpython-36.opt-2.pyc File 58.23 KB 0644
_header_value_parser.cpython-36.pyc File 74.39 KB 0644
_parseaddr.cpython-36.opt-1.pyc File 12.21 KB 0644
_parseaddr.cpython-36.opt-2.pyc File 9.32 KB 0644
_parseaddr.cpython-36.pyc File 12.21 KB 0644
_policybase.cpython-36.opt-1.pyc File 14.93 KB 0644
_policybase.cpython-36.opt-2.pyc File 5.88 KB 0644
_policybase.cpython-36.pyc File 14.93 KB 0644
base64mime.cpython-36.opt-1.pyc File 3.14 KB 0644
base64mime.cpython-36.opt-2.pyc File 1.41 KB 0644
base64mime.cpython-36.pyc File 3.14 KB 0644
charset.cpython-36.opt-1.pyc File 11.21 KB 0644
charset.cpython-36.opt-2.pyc File 5.02 KB 0644
charset.cpython-36.pyc File 11.24 KB 0644
contentmanager.cpython-36.opt-1.pyc File 7.12 KB 0644
contentmanager.cpython-36.opt-2.pyc File 7.12 KB 0644
contentmanager.cpython-36.pyc File 7.12 KB 0644
encoders.cpython-36.opt-1.pyc File 1.6 KB 0644
encoders.cpython-36.opt-2.pyc File 1.26 KB 0644
encoders.cpython-36.pyc File 1.6 KB 0644
errors.cpython-36.opt-1.pyc File 6.2 KB 0644
errors.cpython-36.opt-2.pyc File 4.66 KB 0644
errors.cpython-36.pyc File 6.2 KB 0644
feedparser.cpython-36.opt-1.pyc File 10.25 KB 0644
feedparser.cpython-36.opt-2.pyc File 8.62 KB 0644
feedparser.cpython-36.pyc File 10.4 KB 0644
generator.cpython-36.opt-1.pyc File 12.63 KB 0644
generator.cpython-36.opt-2.pyc File 9.02 KB 0644
generator.cpython-36.pyc File 12.63 KB 0644
header.cpython-36.opt-1.pyc File 16.1 KB 0644
header.cpython-36.opt-2.pyc File 10.6 KB 0644
header.cpython-36.pyc File 16.1 KB 0644
headerregistry.cpython-36.opt-1.pyc File 20.73 KB 0644
headerregistry.cpython-36.opt-2.pyc File 15.09 KB 0644
headerregistry.cpython-36.pyc File 20.78 KB 0644
iterators.cpython-36.opt-1.pyc File 1.87 KB 0644
iterators.cpython-36.opt-2.pyc File 1.26 KB 0644
iterators.cpython-36.pyc File 1.87 KB 0644
message.cpython-36.opt-1.pyc File 37.1 KB 0644
message.cpython-36.opt-2.pyc File 20.9 KB 0644
message.cpython-36.pyc File 37.1 KB 0644
parser.cpython-36.opt-1.pyc File 5.59 KB 0644
parser.cpython-36.opt-2.pyc File 2.64 KB 0644
parser.cpython-36.pyc File 5.59 KB 0644
policy.cpython-36.opt-1.pyc File 9.39 KB 0644
policy.cpython-36.opt-2.pyc File 3.32 KB 0644
policy.cpython-36.pyc File 9.39 KB 0644
quoprimime.cpython-36.opt-1.pyc File 7.5 KB 0644
quoprimime.cpython-36.opt-2.pyc File 4.11 KB 0644
quoprimime.cpython-36.pyc File 7.5 KB 0644
utils.cpython-36.opt-1.pyc File 12.9 KB 0644
utils.cpython-36.opt-2.pyc File 9.21 KB 0644
utils.cpython-36.pyc File 12.9 KB 0644