HEX
Server: Apache
System: Linux bd12.noc223.com 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: handcraf (1693)
PHP: 8.1.28
Disabled: NONE
Upload Files
File: //opt/alt/python312/lib64/python3.12/test/test_email/__pycache__/test_email.cpython-312.pyc
�

}h�e�M��.�ddlZddlZddlZddlZddlZddlmZmZddlm	Z	ddl
mZddlm
Z
ddlmZddlZddlZddlmZddlmZmZmZdd	lmZmZmZdd
lmZddlmZddl m!Z!dd
l"m#Z#ddl$m%Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+ddl,m-Z-ddl.m/Z/ddl0m1Z1m2Z2ddlm3Z3ddlm4Z4ddlm5Z5ddlm6Z6ddlm7Z7ddlm8Z8ddl9m:Z:ddl;m<Z<ddl=m>Z>ddl?m@Z@mAZAddl0mBZBd ZCd!ZDd"ZEGd#�d$eA�ZFGd%�d&ej��ZHGd'�d(eA�ZIGd)�d*ej��ZJGd+�d,ej��ZKGd-�d.ej��ZLGd/�d0ej��ZMGd1�d2ej��ZNGd3�d4eA�ZOGd5�d6eA�ZPGd7�d8eA�ZQGd9�d:eA�ZRGd;�d<eA�ZSGd=�d>eA�ZTGd?�d@eA�ZUGdA�dBeA�ZVGdC�dDeA�ZWGdE�dFeA�ZXGdG�dHeA�ZYGdI�dJ�ZZGdK�dLeZeT�Z[GdM�dNeZeT�Z\GdO�dPej��Z]GdQ�dRej��Z^GdS�dTej��Z_GdU�dVeA�Z`GdW�dXeA�ZaGdY�dZeA�ZbGd[�d\eA�Zcedd]k(rej��yy)^�N)�StringIO�BytesIO)�chain��choice)�Thread)�patch)�Charset)�	Generator�DecodedGenerator�BytesGenerator)�Header�
decode_header�make_header)�HeaderRegistry)�Message)�MIMEApplication)�	MIMEAudio)�MIMEBase)�	MIMEImage)�MIMEMessage)�
MIMEMultipart)�MIMENonMultipart)�MIMEText)�Parser�HeaderParser)�
base64mime)�encoders��errors)�	iterators)�
quoprimime)�utils)�support)�threading_helper)�unlink)�openfile�
TestEmailBase)�
FeedParser�
�� c�
�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&d%�Z'd&�Z(d'�Z)d(�Z*d)�Z+d*�Z,d+�Z-d,�Z.d-�Z/d.�Z0d/�Z1d0�Z2d1�Z3d2�Z4d3�Z5d4�Z6d5�Z7d6�Z8d7�Z9d8�Z:d9�Z;d:�Z<d;�Z=d<�Z>d=�Z?d>�Z@d?�ZAd@�ZBdA�ZCdB�ZDdC�ZEdD�ZFdE�ZGdF�ZHdG�ZIdH�ZJdI�ZKdJ�ZLdK�ZMdL�ZNdM�ZOdN�ZPdO�ZQdP�ZRdQ�ZSdR�ZTdS�ZUdT�ZVdU�ZWyV)W�TestMessageAPIc��|j}|jd�}||jd�gd��||jdd�d�y)Nz
msg_20.txt�cc)zccc@zzz.orgzddd@zzz.orgzeee@zzz.org�xxzn/a)�assertEqual�_msgobj�get_all��self�eq�msgs   �A/opt/alt/python312/lib64/python3.12/test/test_email/test_email.py�test_get_allzTestMessageAPI.test_get_all9sD��
�
�
���l�l�<�(��
�3�;�;�t��K�L�
�3�;�;�t�U�#�U�+�c��|j}t�}||j�d�td�}|j	|�||dd�||j�d�||dd�||j
d�d�||dd	�||j�jd�|j	d�||j�d�||dd�t�}d
|d<d|d
<d|d<|j	|�||dd
�||dd�||dd�y)N�
iso-8859-1�mime-versionz1.0�
text/plain�content-typez text/plain; charset="iso-8859-1"�charset�content-transfer-encoding�quoted-printablez2.0zMIME-Versionztext/x-weird�Content-Typezquinted-puntable�Content-Transfer-Encodingz"text/x-weird; charset="iso-8859-1")r2r�get_charsetr
�set_charset�get_content_type�	get_param�
input_charset�r6r7r8rAs    r9�test_getset_charsetz"TestMessageAPI.test_getset_charset?s6��
�
�
���i��
�3�?�?��d�#��,�'������ �
�3�~���&�
�3���!�<�0�
�3�~�� B�C�
�3�=�=��#�\�2�
�3�*�+�-?�@�
�3�?�?��*�*�L�9������
�3�?�?��d�#�
�3�~���-��i��#��N��,��N��+=��'�(����� �
�3�~���&�
�3�~�� D�E�
�3�*�+�-?�@r;c��|j}t�}|jd�||j�jd�||dd�y)N�us-asciir@�text/plain; charset="us-ascii")r2rrGrFrJr5s   r9�test_set_charset_from_stringz+TestMessageAPI.test_set_charset_from_stringYsG��
�
�
���i�����
�#�
�3�?�?��*�*�J�7�
�3�~�� @�Ar;c��t�}td�}|jd|�|j|j	�j
d�y)Nr=zThis is a string payload)rr
�set_payloadr2rFrJ)r6r8rAs   r9�test_set_payload_with_charsetz,TestMessageAPI.test_set_payload_with_charset`s?���i���,�'�����2�G�<�������*�8�8�,�Gr;c��d}td�}t�}|j||�|j|dd�|j|j	d��|�|j|j	�d�y)N�АБВ�utf-8rB�base64T��decodez	0JDQkdCS
)r
rrRr2�get_payload�r6�datarAr8s    r9�+test_set_payload_with_8bit_data_and_charsetz:TestMessageAPI.test_set_payload_with_8bit_data_and_charsetfsn��*���'�"���i������g�&�����8�9�8�D���������5�t�<�������*�L�9r;c���d}td�}d|_t�}|j|j	d�|�|j|dd�|j|j
d��|�y�NrUrVrB�8bitTrX)r
�
body_encodingrrRrYr2rZr[s    r9�>test_set_payload_with_non_ascii_and_charset_body_encoding_nonezMTestMessageAPI.test_set_payload_with_non_ascii_and_charset_body_encoding_noneosh��*���'�"�� $����i��������G�,�g�6�����8�9�6�B���������5�t�<r;c���d}td�}d|_t�}|j||�|j	|dd�|j	|jd��|�yr_)r
rarrRr2rZr[s    r9�>test_set_payload_with_8bit_data_and_charset_body_encoding_nonezMTestMessageAPI.test_set_payload_with_8bit_data_and_charset_body_encoding_nonexs_��*���'�"�� $����i������g�&�����8�9�6�B���������5�t�<r;c�z�t�}|jg�|j|j�g�y�N�rrRr2rZ�r6r8s  r9�test_set_payload_to_listz'TestMessageAPI.test_set_payload_to_list�s,���i�������������*�B�/r;c��t�}d|d<|jd�tt��}|jtd|j
|�y)N�multipart/mixedrDzstring payloadz[Aa]ttach.*non-multipart)rrRr�assertRaisesRegex�	TypeError�attach)r6r8�sub_msgs   r9�"test_attach_when_payload_is_stringz1TestMessageAPI.test_attach_when_payload_is_string�sH���i��/��N�����(�)��g�i�(�����y�*D�"�z�z�7�	4r;c�&�|j}|jd�}|j�}||gd��|jd�}|jd�}||gd��|jd�}|j�}||gd��y)Nz
msg_08.txt)NrNr=�
iso-8859-2�koi8-rz
msg_09.txt�dingbat)rtrNr=rtrsz
msg_12.txt)NrNr=Nrrz
iso-8859-3rNrs)r2r3�get_charsets)r6r7r8�charsetss    r9�test_get_charsetsz TestMessageAPI.test_get_charsets�s���
�
�
���l�l�<�(���#�#�%��
�8�M�N��l�l�<�(���#�#�I�.��
�8� �	!��l�l�<�(���#�#�%��
�8�:�	;r;c�&�|j}|jd�}|j�D�cgc]}|j���}}||ddg�|jd�}|jd�}||j�d�ycc}w)N�
msg_04.txt�msg.txt�
msg_07.txt��dingusfish.gif�r2r3rZ�get_filename)r6r7r8�p�	filenames�subparts      r9�test_get_filenamez TestMessageAPI.test_get_filename�s���
�
�
���l�l�<�(��/2���/@�A�!�Q�^�^�%�A�	�A�
�9�y�)�,�-��l�l�<�(���/�/�!�$��
�7���!�#3�4��Bs�Bc��|j}|jd�}|j�D�cgc]}|j���}}||ddg�ycc}w)Nz
msg_44.txtrzr~)r6r7r8r�r�s     r9�%test_get_filename_with_name_parameterz4TestMessageAPI.test_get_filename_with_name_parameter�sQ��
�
�
���l�l�<�(��/2���/@�A�!�Q�^�^�%�A�	�A�
�9�y�)�,�-��Bs�Ac�l�|j}|jd�}||j�d�y)Nr{�BOUNDARY)r2r3�get_boundaryr5s   r9�test_get_boundaryz TestMessageAPI.test_get_boundary�s.��
�
�
���l�l�<�(��
�3����z�*r;c���|j}|jd�}|jd�|j�d\}}||j	�d�||d�|jd�}|jd�|j�d\}}||j	�d�||d�|jd�}|jtj|jd�y)	N�
msg_01.txtr��r@z3text/plain; charset="us-ascii"; boundary="BOUNDARY"ryz$multipart/mixed; boundary="BOUNDARY"�
msg_03.txt)r2r3�set_boundary�items�lower�assertRaisesr �HeaderParseError)r6r7r8�header�values     r9�test_set_boundaryz TestMessageAPI.test_set_boundary�s���
�
�
���l�l�<�(������$��	�	��A��
���
�6�<�<�>�>�*�
�5�G�H��l�l�<�(������$��	�	��A��
���
�6�<�<�>�>�*�
�5�8�9��l�l�<�(�����&�1�1��*�*�J�	8r;c���td�}|j|j�ddd�|j�|j|j�ddddd�y)Nz	form-datarr|zmultipart/form-data�!z!multipart/form-data; boundary="==)rr2r��	as_stringrhs  r9�test_make_boundaryz!TestMessageAPI.test_make_boundary�s`���K�(��	
�������Q���*�,A�B��
�
���������Q���*�3�B�/�;�	=r;c�0�tdd��5}|j�}ddd�t�}|j�}t	�}t|dd�}|j
|d�|j|j�|�y#1swY�nxYw)N�
msg_46.txtrV��encodingTrF)	r'�readr�parsestrrr�flattenr2�getvalue�r6�fp�msgdata�parserr8�out�gens       r9�test_message_rfc822_onlyz'TestMessageAPI.test_message_rfc822_only�s~���l�W�
5�	 ���g�g�i�G�	 �����o�o�g�&���j����T�1�%�����C�����������1�	 �	 �s�B�Bc��tdd��5}|j�jd�}ddd�tjj�}|j
�}t�}tjj|�}|j|�|j|j�|�y#1swY��xYw)Nr�rVr��ascii)
r'r��encode�emailr��BytesHeaderParser�
parsebytesr�	generatorr
r�r2r�r�s       r9�test_byte_message_rfc822_onlyz,TestMessageAPI.test_byte_message_rfc822_only�s���
�l�W�
5�	0���g�g�i�&�&�w�/�G�	0����/�/�1������(���i���o�o�,�,�S�1�����C����������1�	0�	0�s� C�C	c��|j}|jd�}||jd��d�||jd�jd��d�||jd�jd��d�||jd�jd��d	�||jd
�jd��d�||jd�jd��d
�y)Nz
msg_10.txtTrXrs This is a 7bit encoded message.
r|s-�This is a Quoted Printable encoded message!
�s!This is a Base64 encoded message.�s"This is a Base64 encoded message.
r�s/This has no Content-Transfer-Encoding: header.
)r2r3rZr5s   r9�test_get_decoded_payloadz'TestMessageAPI.test_get_decoded_payload�s���
�
�
���l�l�<�(��
�3�?�?�$�?�'��.�
�3�?�?�1��)�)��)�6�/�	1�	�3�?�?�1��)�)��)�6�?�	A�	�3�?�?�1��)�)��)�6�/�	1�	�3�?�?�1��)�)��)�6�1�	3�	�3�?�?�1��)�)��)�6�>�	@r;c���|j}t�}|jd�dD] }||d<||jd��d��"|jd�||jd��d�y)	Nz$begin 666 -
+:&5L;&\@=V]R;&0 
 
end
�z
x-uuencode�uuencode�uuezx-uuerBTrX�hello world�foosfoo)r2rrRrZ)r6r7r8�ctes    r9�test_get_decoded_uu_payloadz*TestMessageAPI.test_get_decoded_uu_payloadss��
�
�
���i�����C�D�=�	=�C�/2�C�+�,��s���d��+�^�<�	=�	�����
�3�?�?�$�?�'��0r;c�Z�t�}|jt|jd�y)Nr|)rr�rmrZrhs  r9�*test_get_payload_n_raises_on_non_multipartz9TestMessageAPI.test_get_payload_n_raises_on_non_multiparts���i�����)�S�_�_�a�8r;c��|j}|jd�}tdd��5}|j�}ddd�t	�}t|�}|j
|�||j��y#1swY�GxYw)Nr{z
msg_17.txtrVr�)r2r3r'r�rrr�r�)r6r7r8r��text�s�gs       r9�test_decoded_generatorz%TestMessageAPI.test_decoded_generatorss��
�
�
���l�l�<�(��
�l�W�
5�	���7�7�9�D�	��J���Q���	�	�	�#��
�1�:�:�<���	�	�s�B�Bc��t�}d|d<d|d<|jd|�|jd|�|jd|�|jd|�|jd|�|jd|�y)	N�Me�From�You�to�from�FROM�To�TO)r�assertInrhs  r9�test__contains__zTestMessageAPI.test__contains__so���i����F����D�	��
�
�f�c�"��
�
�f�c�"��
�
�f�c�"��
�
�d�C� ��
�
�d�C� ��
�
�d�C� r;c��|jd�}tdd��5}|j�}ddd�|jt	|��|jd��}|j
d�}|j|djd��|j|tj|d	d��y#1swY��xYw)
Nr�rVr�T��unixfromr*rzFrom r|)r3r'r�r2�strr��split�
assertTrue�
startswith�NL�join)r6r8r�r��fullrepr�liness      r9�test_as_stringzTestMessageAPI.test_as_string*s����l�l�<�(��
�l�W�
5�	���7�7�9�D�	�����s�3�x�(��=�=�$�=�/�����t�$������a��+�+�G�4�5�����r�w�w�u�Q�R�y�1�2�
	�	�s�C�Cc��|jd�}|jjd��}|j|��}t	�}t||��}|j
|�|j||j��y�Nr��
��linesep��policy)	r3r��cloner�rrr�r2r��r6r8�	newpolicyr�r�r�s      r9�test_as_string_policyz$TestMessageAPI.test_as_string_policy4sk���l�l�<�(���J�J�$�$�V�$�4�	��=�=�	�=�2���J���a�	�*��	�	�	�#������1�:�:�<�0r;c���tjd�}|jd�}tjd�}tj|�}|j|j
�|�y)Nu�            MIME-Version: 1.0
            Content-type: text/plain; charset="iso-8859-1"

            Test if non-ascii messages with no Content-Transfer-Encoding set
            can be as_string'd:
            Föö bär
            r=a%            MIME-Version: 1.0
            Content-type: text/plain; charset="iso-8859-1"
            Content-Transfer-Encoding: quoted-printable

            Test if non-ascii messages with no Content-Transfer-Encoding set
            can be as_string'd:
            F=F6=F6 b=E4r
            )�textwrap�dedentr�r��message_from_bytesr2r��r6�m�source�expectedr8s     r9�#test_nonascii_as_string_without_ctez2TestMessageAPI.test_nonascii_as_string_without_cte=s`���O�O��
�����,�'���?�?�$����&�&�v�.���������(�3r;c���tjd�}|jd�}|jdd�}t	j
|�}|j
|j�|�y)Nu�            MIME-Version: 1.0

            Test if non-ascii messages with no Content-Type nor
            Content-Transfer-Encoding set can be as_string'd:
            Föö bär
            r=r��replace)r�r�r�rYr�r�r2r�r�s     r9�4test_nonascii_as_string_without_content_type_and_ctezCTestMessageAPI.test_nonascii_as_string_without_content_type_and_cteSs[���O�O��
�����,�'���=�=��)�4���&�&�v�.���������(�3r;c��|jd�}tdd��5}|j�jd�}ddd�|j	t|��|j
d��}|jd�}|j|djd	��|j	|dj|d
d��y#1swY��xYw)Nr�rVr�r�Tr��
rsFrom r|)r3r'r�r�r2�bytes�as_bytesr�r�r�r�)r6r8r�r\r�r�s      r9�
test_as_byteszTestMessageAPI.test_as_bytes`s����l�l�<�(��
�l�W�
5�	-���7�7�9�#�#�G�,�D�	-�����u�S�z�*��<�<��<�.�����u�%������a��+�+�H�5�6�����u�z�z�%���)�4�5�
	-�	-�s� C
�
Cc��|jd�}|jjd��}|j|��}t	�}t||��}|j
|�|j||j��yr�)	r3r�r�r�rr
r�r2r�r�s      r9�test_as_bytes_policyz#TestMessageAPI.test_as_bytes_policyjsk���l�l�<�(���J�J�$�$�V�$�4�	��<�<�y�<�1���I���1�I�.��	�	�	�#������1�:�:�<�0r;c�p�tjd�}|j|jd�d�y)NzContent-Type: blarg; baz; boo
�bazr+�r��message_from_stringr2rIrhs  r9�test_bad_paramzTestMessageAPI.test_bad_paramts,���'�'�(I�J��������u�-�r�2r;c�n�tjd�}|j|j�d�y�Nz
From: foo
�r�r�r2rrhs  r9�test_missing_filenamez$TestMessageAPI.test_missing_filenamex�+���'�'�
�6������)�)�+�T�2r;c�n�tjd�}|j|j�d�y)Nz%Content-Disposition: blarg; filename
r+rrhs  r9�test_bogus_filenamez"TestMessageAPI.test_bogus_filename|s.���'�'�0�2������)�)�+�R�0r;c�n�tjd�}|j|j�d�yr��r�r�r2r�rhs  r9�test_missing_boundaryz$TestMessageAPI.test_missing_boundary�rr;c�j�|j}tjd�}||jd��gd��tjd�}||jd��gd��||j�d�tjd�}||jd��gd��y)N�&X-Header: foo=one; bar=two; baz=three
�x-header�r�))r��one)�bar�two�r��threez X-Header: foo; bar=one; baz=two
))r�r+)r
r)r�r�"X-Header: foo; bar="one"; baz=two
)r2r�r��
get_paramsr5s   r9�test_get_paramszTestMessageAPI.test_get_params�s���
�
�
���'�'�5�7��
�3�>�>��>�,�=�	?��'�'�/�1��
�3�>�>��>�,�8�	:�
�3�>�>��T�"��'�'�1�3��
�3�>�>��>�,�8�	:r;c�d�t�}d|d<|j|jd�d�y)Nz>Content-Type: Multipart/mixed; boundary = "CPIMSSMTPC06p5f3tG"rD�boundary�CPIMSSMTPC06p5f3tG)rr2rIrhs  r9�test_get_param_liberalz%TestMessageAPI.test_get_param_liberal�s-���i��^��N��������z�2�4H�Ir;c��|j}tjd�}||jdd��d�||jdd��d�||jd�d�tjd�}||jdd��d	�||jdd��d
�||jdd��d�y)Nr	r
r
rr�quuzrr�r+rr��r2r�r�rIr5s   r9�test_get_paramzTestMessageAPI.test_get_param�s���
�
�
���'�'�5�7��
�3�=�=��z�=�2�E�:�
�3�=�=��
�=�3�T�:�
�3�=�=�� �$�'��'�'�1�3��
�3�=�=��z�=�2�B�7�
�3�=�=��z�=�2�E�:�
�3�=�=��z�=�2�E�:r;c��|jd�}|j|jd�jd�d�y)Nz
msg_22.txtr|�namez
wibble.JPG)r3r2rZrIrhs  r9�'test_get_param_funky_continuation_linesz6TestMessageAPI.test_get_param_funky_continuation_lines�s4���l�l�<�(���������+�5�5�f�=�|�Lr;c��tjd�}|j|jd�d�|j|jdd��d�y)Nz4Content-Type: image/pjpeg; name="Jim&amp;&amp;Jill"
rzJim&amp;&amp;JillF��unquotez"Jim&amp;&amp;Jill"r�rhs  r9�#test_get_param_with_semis_in_quotesz2TestMessageAPI.test_get_param_with_semis_in_quotes�sP���'�'�C�E��������v�.�0C�D�������v�u��=�.�	0r;c���tjd�}|j|jd�d�tjd�}|j|jd�d�y)Nz5Content-Type: foo; bar*0="baz\"foobar"; bar*1="\"baz"r
zbaz"foobar"bazr�rhs  r9�test_get_param_with_quotesz)TestMessageAPI.test_get_param_with_quotes�s^���'�'�E�G��������u�-�/?�@��'�'�K�M��������u�-�/?�@r;c��tjd�}|jd|�|jd|�|jd|�|jd|�y)NzHeader: existsr�r�HEADER�headerx)r�r�r��assertNotInrhs  r9�test_field_containmentz%TestMessageAPI.test_field_containment�sM���'�'�(8�9���
�
�h��$��
�
�h��$��
�
�h��$�����C�(r;c���|j}t�}|jdd�||jd�d�|jdd�||jd�d�||jdd��d�||j	�gd��||j	d��gd	��|jdd
d��||jdd��d
�y)
NrA�iso-2022-jp�
importance�
high valueFr �"high value")�r?r+)rAr+)r,r-)r/)rAz
"iso-2022-jp")r,r.ziso-9999-xxzX-Jimmyr)r2r�	set_paramrIrr5s   r9�test_set_paramzTestMessageAPI.test_set_param�s���
�
�
���i���
�
�i��/�
�3�=�=��#�]�3��
�
�l�L�1�
�3�=�=��&��5�
�3�=�=��u�=�5�~�F�
�3�>�>��<�	=�	�3�>�>�%�>�(�+G�	H�	�
�
�i��y�
�A�
�3�=�=��9�=�5�}�Er;c�B�|j}|jd�}||j�gd��|jd�}|j	d�||j�ddg�|jd|�||j�ddd|fg�y)N�
msg_05.txt)��multipart/reportr+)�report-type�delivery-status�r�%D1690A7AC1.996856090/mail.example.comr6r4r8)r2r3rrI�	del_paramr0)r6r7r8�old_vals    r9�test_del_paramzTestMessageAPI.test_del_param�s���
�
�
���l�l�<�(��
�3�>�>��C�	D��-�-�
�.���
�
�m�$�
�3�>�>��$�A�C�	D�	�
�
�m�W�-�
�3�>�>��$�A�
�G�$�&�	'r;c��t�}|jddd��|jdd�|j|dd�y)N�Content-Disposition�
attachment�bud.gif��filenamerB�content-disposition�r�
add_headerr:r2rhs  r9�test_del_param_on_other_headerz-TestMessageAPI.test_del_param_on_other_header�sA���i�����,�l�Y��O��
�
�j�"7�8�����2�3�\�Br;c�<�t�}|jdd�y)NrBrC)rr:rhs  r9�$test_del_param_on_nonexistent_headerz3TestMessageAPI.test_del_param_on_nonexistent_header�s���i���
�
�j�"7�8r;c��t�}|jddd��|d}|jdd��|j|d|�y)NrDr?rV�rA�foobarrrD)r6r8�existing_headers   r9�test_del_nonexistent_paramz)TestMessageAPI.test_del_nonexistent_param�sJ���i�����~�|�W��E��n�-���
�
�h�~�
�6�����^�,�o�>r;c�"�|j}t�}|jt|jd�|j	d�||dd�|jdd�||dd�|j	d�||dd�y)	Nr�r?r@rArNrOz	text/htmlztext/html; charset="us-ascii")r2rr��
ValueError�set_typer0r5s   r9�
test_set_typezTestMessageAPI.test_set_type�s��
�
�
���i�����*�c�l�l�F�;����\�"�
�3�~���-��
�
�i��,�
�3�~�� @�A����[�!�
�3�~�� ?�@r;c�p�t�}d|d<|jdd�|j|dd�y)Nr?zX-Content-Type�application/octet-streamzx-content-type)rrPr2rhs  r9�test_set_type_on_other_headerz,TestMessageAPI.test_set_type_on_other_headers;���i�� ,�������/�1A�B�����-�.�0J�Kr;c�X�t�}|j|j�d�y)Nr?)rr2rHrhs  r9�test_get_content_type_missingz,TestMessageAPI.test_get_content_type_missings"���i������-�-�/��>r;c�z�t�}|jd�|j|j�d�y)N�message/rfc822)r�set_default_typer2rHrhs  r9�/test_get_content_type_missing_with_default_typez>TestMessageAPI.test_get_content_type_missing_with_default_types2���i�����-�.�����-�-�/�1A�Br;c��|jd�}|j|jd�j�d�y)N�
msg_30.txtrrX�r3r2rZrHrhs  r9�+test_get_content_type_from_message_implicitz:TestMessageAPI.test_get_content_type_from_message_implicit�5���l�l�<�(���������+�<�<�>�)�	+r;c��|jd�}|j|jd�j�d�y)N�
msg_28.txtrrXr]rhs  r9�+test_get_content_type_from_message_explicitz:TestMessageAPI.test_get_content_type_from_message_explicitr_r;c�f�|jd�}|j|j�d�y)Nr�r?�r3r2rHrhs  r9�6test_get_content_type_from_message_text_plain_implicitzETestMessageAPI.test_get_content_type_from_message_text_plain_implicit!�)���l�l�<�(������-�-�/��>r;c�f�|jd�}|j|j�d�y)Nr�r?rdrhs  r9�6test_get_content_type_from_message_text_plain_explicitzETestMessageAPI.test_get_content_type_from_message_text_plain_explicit%rfr;c�X�t�}|j|j�d�y)Nr��rr2�get_content_maintyperhs  r9�!test_get_content_maintype_missingz0TestMessageAPI.test_get_content_maintype_missing)s"���i������1�1�3�V�<r;c�z�t�}|jd�|j|j�d�y)NrX�message)rrYr2rkrhs  r9�3test_get_content_maintype_missing_with_default_typezBTestMessageAPI.test_get_content_maintype_missing_with_default_type-s1���i�����-�.�����1�1�3�Y�?r;c��|jd�}|j|jd�j�d�y)Nr\rrn�r3r2rZrkrhs  r9�/test_get_content_maintype_from_message_implicitz>TestMessageAPI.test_get_content_maintype_from_message_implicit2�2���l�l�<�(���������+�@�@�B�I�Nr;c��|jd�}|j|jd�j�d�y)Nrarrnrqrhs  r9�/test_get_content_maintype_from_message_explicitz>TestMessageAPI.test_get_content_maintype_from_message_explicit6rsr;c�f�|jd�}|j|j�d�y)Nr�r��r3r2rkrhs  r9�:test_get_content_maintype_from_message_text_plain_implicitzITestMessageAPI.test_get_content_maintype_from_message_text_plain_implicit:�)���l�l�<�(������1�1�3�V�<r;c�f�|jd�}|j|j�d�y)Nr�r�rwrhs  r9�:test_get_content_maintype_from_message_text_plain_explicitzITestMessageAPI.test_get_content_maintype_from_message_text_plain_explicit>ryr;c�X�t�}|j|j�d�y)N�plain�rr2�get_content_subtyperhs  r9� test_get_content_subtype_missingz/TestMessageAPI.test_get_content_subtype_missingBs"���i������0�0�2�G�<r;c�z�t�}|jd�|j|j�d�y)NrX�rfc822)rrYr2rrhs  r9�2test_get_content_subtype_missing_with_default_typezATestMessageAPI.test_get_content_subtype_missing_with_default_typeFs1���i�����-�.�����0�0�2�H�=r;c��|jd�}|j|jd�j�d�y)Nr\rr��r3r2rZrrhs  r9�.test_get_content_subtype_from_message_implicitz=TestMessageAPI.test_get_content_subtype_from_message_implicitK�2���l�l�<�(���������+�?�?�A�8�Lr;c��|jd�}|j|jd�j�d�y)Nrarr�r�rhs  r9�.test_get_content_subtype_from_message_explicitz=TestMessageAPI.test_get_content_subtype_from_message_explicitOr�r;c�f�|jd�}|j|j�d�y)Nr�r}�r3r2rrhs  r9�9test_get_content_subtype_from_message_text_plain_implicitzHTestMessageAPI.test_get_content_subtype_from_message_text_plain_implicitS�)���l�l�<�(������0�0�2�G�<r;c�f�|jd�}|j|j�d�y)Nr�r}r�rhs  r9�9test_get_content_subtype_from_message_text_plain_explicitzHTestMessageAPI.test_get_content_subtype_from_message_text_plain_explicitWr�r;c�b�t�}d|d<|j|j�d�y)N�no-slash-in-this-stringrDr�rjrhs  r9�test_get_content_maintype_errorz.TestMessageAPI.test_get_content_maintype_error[s,���i��7��N������1�1�3�V�<r;c�b�t�}d|d<|j|j�d�y)Nr�rDr}r~rhs  r9�test_get_content_subtype_errorz-TestMessageAPI.test_get_content_subtype_error`s,���i��7��N������0�0�2�G�<r;c�x�|j}t�}|jdd�|jdd�|jdd�||j�gd��||j	�gd��|jdd	�||j�gd��||j	�gd
��|jdd�|jdd�||j�gd
��||j	�gd��|j
t|j
dd�y)N�First�One�Second�Two�Third�Three)r�r�r�)r�r�r��Twenty)r�r�r��Eleven�One Hundred)r�r�r�r�)r�r�r�r��Fourth�Missing)r2rrE�keys�values�replace_headerr��KeyErrorr5s   r9�test_replace_headerz"TestMessageAPI.test_replace_headeres���
�
�
���i�����w��&����x��'����w��(�
�3�8�8�:�3�4�
�3�:�:�<�0�1����8�X�.�
�3�8�8�:�3�4�
�3�:�:�<�3�4����w��)����7�M�2�
�3�8�8�:�<�=�
�3�:�:�<�E�F����(�C�$6�$6��)�Lr;c��t�}|j|j��|jddd��|j	|j�d�|jdd�|j	|j�d�|jdd�|j	|j�d�y)Nr>r?z
random.avirA�inline�InlinE)r�assertIsNone�get_content_dispositionrEr2r�rhs  r9�test_get_content_dispositionz+TestMessageAPI.test_get_content_dispositionvs����i�����#�5�5�7�8����,�l� ,�	�	.�����4�4�6��E����0�(�;�����4�4�6��A����0�(�;�����4�4�6��Ar;c���d}t�}d|d<d|d<|j|�|j|jd��d�|j	|j
d	tj�y)
NzAwDp0P7//y6LwKEAcPa/6Q=9zaudio/x-midir@rWrBTrXs����.���p���r)rrRr2rZ�assertIsInstance�defectsr �InvalidBase64CharactersDefect�r6�xr8s   r9�test_broken_base64_payloadz)TestMessageAPI.test_broken_base64_payload�ss��&���i��,��N��+3��'�(��������������5�7�	9�	
���c�k�k�!�n�$�B�B�	Dr;c��d}t�}d|d<d|d<|j|�|j|jd��t	|d��y)	Nuthis is a bröken thing to dor?r@r`rBTrXzraw-unicode-escape)rrRr2rZr�r�s   r9�test_broken_unicode_payloadz*TestMessageAPI.test_broken_unicode_payload�sW��
.���i��*��N��+1��'�(��������������5��q�"6�7�	9r;c��djd�}t�}d|d<d|d<||_|j|j	d��|�y)	Nu#this is a quéstionable thing to dorV�text/plain; charset="utf-8"r@r`rBTrX)r�r�_payloadr2rZr�s   r9�test_questionable_bytes_payloadz.TestMessageAPI.test_questionable_bytes_payload�sR��
2�8�8��A���i��;��N��+1��'�(������������5�q�9r;c�j�t�}|jddd��|jd|d�y)Nr>r?r@rAzattachment; filename="bud.gif"�rrEr2rhs  r9�test_ascii_add_headerz$TestMessageAPI.test_ascii_add_header�s<���i�����,�l� )�	�	+����9��%�&�	(r;c�j�t�}|jddd��|jd|d�y)Nr>r?�Fußballer.pptrAz/attachment; filename*=utf-8''Fu%C3%9Fballer.pptr�rhs  r9�test_noascii_add_headerz&TestMessageAPI.test_noascii_add_header�s<���i�����,�l�%�	�	'����?��%�&�	(r;c�j�t�}|jddd��|jd|d�y)Nr>r?)r=r+r�rAz1attachment; filename*=iso-8859-1''Fu%DFballer.pptr�rhs  r9�#test_nonascii_add_header_via_triplez2TestMessageAPI.test_nonascii_add_header_via_triple�s<���i�����,�l�9�	�	;����A��%�&�	(r;c�j�t�}|jddd��|jd|d�y)Nr>r?zwindows [filename].pptrAz-attachment; filename="windows [filename].ppt"r�rhs  r9�#test_ascii_add_header_with_tspecialz2TestMessageAPI.test_ascii_add_header_with_tspecial�s<���i�����,�l�-�	�	/����;��%�&�	(r;c�j�t�}|jddd��|jd|d�y)Nr>r?uFußballer [filename].pptrAz@attachment; filename*=utf-8''Fu%C3%9Fballer%20%5Bfilename%5D.pptr�rhs  r9�&test_nonascii_add_header_with_tspecialz5TestMessageAPI.test_nonascii_add_header_with_tspecial�s<���i�����,�l�0�	�	2����N��%�&�	(r;c��dD]P}t�}d|z|d<d|d<|jd�|j|jd��d	d
|z��Ry)N��latin-1r��text/plain; charset=%sr@rCrBsfoo=e6=96=87barTrX�	foo文bar�1get_payload returns wrong result with charset %s.rg�r6rAr8s   r9�test_binary_quopri_payloadz)TestMessageAPI.test_binary_quopri_payload�si��+�	O�G��)�C�":�W�"D�C���/A�C�+�,��O�O�.�/�������t��,�%�C�g�M�
O�	Or;c��dD]P}t�}d|z|d<d|d<|jd�|j|jd��d	d
|z��Ry)Nr�r�r@rWrBsZm9v5paHYmFyTrXr�r�rgr�s   r9�test_binary_base64_payloadz)TestMessageAPI.test_binary_base64_payload�sh��+�	O�G��)�C�":�W�"D�C���/7�C�+�,��O�O�O�,�������t��,�%�C�g�M�
O�	Or;c
���dD]m}dD]f}t�}d|z|d<||d<|jd�|j|jd��d	t	d
�j||���h�oy)Nr�r�r�r@rBs begin 666 -
)9F]OYI:'8F%R
 
end
TrXr�)z!get_payload returns wrong result z"with charset {0} and encoding {1}.)rrRr2rZr��format)r6rAr�r8s    r9�test_binary_uuencode_payloadz+TestMessageAPI.test_binary_uuencode_payload�s���+�	3�G�F�

3���i��&>��&H��N�#�3;��/�0���� G�H�� � ��O�O�4�O�0�)��?�@���w��1�3�

3�	3r;c�j�t�}|jddd��|jd|d�y)Nr>r�)�foo_barzinline; foo-barr�rhs  r9�$test_add_header_with_name_only_paramz3TestMessageAPI.test_add_header_with_name_only_param�s3���i�����,�h���E����*�C�0E�,F�Gr;c�f�t�}|jdd�|jd|d�y)NzX-Statusr+r�rhs  r9�test_add_header_with_no_valuez,TestMessageAPI.test_add_header_with_no_value�s+���i�����z�4�(�����S��_�-r;c��t�}td�|d<|jtj|j
�y�Nzdummy
X-Injected-Header: test�Dummy)rrr�r r�r�rhs  r9�(test_embedded_header_via_Header_rejectedz7TestMessageAPI.test_embedded_header_via_Header_rejected�s2���i���>�?��G�����&�1�1�3�=�=�Ar;c�v�t�}d|d<|jtj|j�yr�)rr�r r�r�rhs  r9�(test_embedded_header_via_string_rejectedz7TestMessageAPI.test_embedded_header_via_string_rejecteds,���i��7��G�����&�1�1�3�=�=�Ar;c��td�}d|d<|jt|�tjd��y)Nzabc
uÉ test�Subjectz�            Content-Type: text/plain; charset="us-ascii"
            MIME-Version: 1.0
            Content-Transfer-Encoding: 7bit
            Subject: =?utf-8?q?=C3=89_test?=

            abc
            �rr2r�r�r��r6r�s  r9�-test_unicode_header_defaults_to_utf8_encodingz<TestMessageAPI.test_unicode_header_defaults_to_utf8_encodings9���W��� ��)������Q�����1�!�	r;c�v�td�}|jt|�tjd��y)NuÉ testabc
z�            Content-Type: text/plain; charset="utf-8"
            MIME-Version: 1.0
            Content-Transfer-Encoding: base64

            w4kgdGVzdGFiYwo=
            r�r�s  r9�+test_unicode_body_defaults_to_utf8_encodingz:TestMessageAPI.test_unicode_body_defaults_to_utf8_encodings0���^�$������Q�����1�!�	r;N)X�__name__�
__module__�__qualname__r:rLrPrSr]rbrdrirprwr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrr"r$r)r1r<rFrHrMrQrTrVrZr^rbrerhrlrorrrurxr{r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��r;r9r.r.8s���,�A�4B�H�:�=�=�0�
4�;�"	5�.�+�8�,=�
2�	2�@�,	1�9��
!�3�1�4�,4�6�1�3�3�1�
3�:�"J�
;�$M�
0�A�)�F�"'�"C�9�
?�	A�L�?�C�
+�
+�
?�?�=�@�
O�O�=�=�=�>�
M�M�=�=�=�
=�
M�"	B�
D�	9�:�(�(�(�(�(�	O�	O�3�H�
.�B�
B�
�	r;r.c�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�TestEncodersc
�h�tdd�5}|j�}ddd�tjjj�}|j
�}|jd�}|jt|D�cgc]
}t|���c}�d�y#1swY��xYwcc}w)N�
python.gif�rbr*�L)r'r�r��mime�imagerrZr��assertLessEqual�max�len)r6r��bindata�mimed�base64edr�r�s       r9�test_EncodersEncode_base64z'TestEncoders.test_EncodersEncode_base64!s���
�l�D�
)�	 �R��g�g�i�G�	 ��
�
� � �*�*�7�3���$�$�&�����t�$�����S�5�!:�a�3�q�6�!:�;�R�@�
	 �	 ��";s�B#�B/�#B,c�j�|j}t�}|jd�||dd�y)NrNrB�7bit)r2rrGr5s   r9�test_encode_empty_payloadz&TestEncoders.test_encode_empty_payload*s0��
�
�
���i�����
�#�
�3�*�+�V�4r;c��|j}td�}||dd�td�}||dd�tdd��}||dd�y)	N�hello worldrBr�uhello ø worldrWr=��_charsetrC)r2rr5s   r9�test_default_ctezTestEncoders.test_default_cte0s`��
�
�
���}�%��
�3�*�+�V�4��)�*��
�3�*�+�X�6��)�L�A��
�3�*�+�-?�@r;c��|j}tdd��}||dd�||j�tjd��y)Nu文
�euc-jpr�rBr�z�            MIME-Version: 1.0
            Content-Type: text/plain; charset="iso-2022-jp"
            Content-Transfer-Encoding: 7bit

            $BJ8(B
            )r2rr�r�r�r5s   r9�test_encode7or8bitzTestEncoders.test_encode7or8bit<sK���
�
���w��2��
�3�*�+�V�4�
�3�=�=�?�H�O�O�-��	r;c�z�tddd�}|jt|�tjd��y)Nuáö
r�z
ISO-8859-1z�            MIME-Version: 1.0
            Content-Type: text/text; charset="iso-8859-1"
            Content-Transfer-Encoding: quoted-printable

            =E1=F6
            r�rhs  r9�test_qp_encode_latin1z"TestEncoders.test_qp_encode_latin1Ks4���|�V�\�:������S��8�?�?�4�$�	r;c�z�tddd�}|jt|�tjd��y)Nuż
r�z
ISO-8859-2z�            MIME-Version: 1.0
            Content-Type: text/text; charset="iso-8859-2"
            Content-Transfer-Encoding: quoted-printable

            =BF
            r�rhs  r9�test_qp_encode_non_latin1z&TestEncoders.test_qp_encode_non_latin1Us4���z�6�<�8������S��8�?�?�4�$�	r;N)	r�r�r�r�r�r�rrrr�r;r9r�r�s"��A�5�
A�
��	r;r�c��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&d%�Z'd&�Z(d'�Z)d(�Z*y))�TestLongHeadersNc��|j}tjd�}t�}t	|�}|j|�||j
�d�y)Nz�Subject: bug demonstration
	12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
	more text

test
)�ndiffAssertEqualr�r�rrr�r��r6r7r8�sfpr�s     r9�test_split_long_continuationz,TestLongHeaders.test_split_long_continuationfsT��
�
"�
"���'�'�)����j���c�N��	�	�	�#��
�3�<�<�>��	r;c���|j}d}t|d��}||j�d�t|jdd��}||j�d�y)Nz�bug demonstration
	12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
	more text�	��continuation_wsr,z�bug demonstration
 12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
 more text)r	rr�r��r6r7�hstr�hs    r9�,test_another_long_almost_unsplittable_headerz<TestLongHeaders.test_another_long_almost_unsplittable_headerzsc��
�
"�
"����
�4��.��
�1�8�8�:��	�
�4�<�<��c�*�+��
�1�8�8�:��	r;c��|j}td�}td�}td�}d}d}d}t||d��}|j||�|j||�t	�}	||	d<t�}
t
|
�}|j|	�||
j�d	�||jd
��d�y)
Nr=rrrV�Die Mieter treten hier ein werden mit einem Foerderband komfortabel den Korridor entlang, an s�dl�ndischen Wandgem�lden vorbei, gegen die rotierenden Klingen bef�rdert. �;Finan�ni metropole se hroutily pod tlakem jejich d�vtipu.. ��正確に言うと翻訳はされていません。一部はドイツ語ですが、あとはでたらめです。実際には「Wenn ist das Nunstuck git und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt gersput.」と言っています。r���header_namea!Subject: =?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerderb?=
 =?iso-8859-1?q?and_komfortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndischen?=
 =?iso-8859-1?q?_Wandgem=E4lden_vorbei=2C_gegen_die_rotierenden_Klingen_bef?=
 =?iso-8859-1?q?=F6rdert=2E_?= =?iso-8859-2?q?Finan=E8ni_metropole_se_hrouti?=
 =?iso-8859-2?q?ly_pod_tlakem_jejich_d=F9vtipu=2E=2E_?= =?utf-8?b?5q2j56K6?=
 =?utf-8?b?44Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE44G+44Gb44KT44CC5LiA?=
 =?utf-8?b?6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB44GC44Go44Gv44Gn44Gf44KJ?=
 =?utf-8?b?44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CMV2VubiBpc3QgZGFzIE51bnN0dWNr?=
 =?utf-8?b?IGdpdCB1bmQgU2xvdGVybWV5ZXI/IEphISBCZWloZXJodW5kIGRhcyBPZGVyIGRp?=
 =?utf-8?b?ZSBGbGlwcGVyd2FsZHQgZ2Vyc3B1dC7jgI3jgajoqIDjgaPjgabjgYTjgb7jgZk=?=
 =?utf-8?b?44CC?=

r���
maxlinelena	=?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerde?=
 =?iso-8859-1?q?rband_komfortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndis?=
 =?iso-8859-1?q?chen_Wandgem=E4lden_vorbei=2C_gegen_die_rotierenden_Klinge?=
 =?iso-8859-1?q?n_bef=F6rdert=2E_?= =?iso-8859-2?q?Finan=E8ni_metropole_se?=
 =?iso-8859-2?q?_hroutily_pod_tlakem_jejich_d=F9vtipu=2E=2E_?=
 =?utf-8?b?5q2j56K644Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE44G+44Gb?=
 =?utf-8?b?44KT44CC5LiA6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB44GC44Go?=
 =?utf-8?b?44Gv44Gn44Gf44KJ44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CMV2VubiBp?=
 =?utf-8?b?c3QgZGFzIE51bnN0dWNrIGdpdCB1bmQgU2xvdGVybWV5ZXI/IEphISBCZWlo?=
 =?utf-8?b?ZXJodW5kIGRhcyBPZGVyIGRpZSBGbGlwcGVyd2FsZHQgZ2Vyc3B1dC7jgI0=?=
 =?utf-8?b?44Go6KiA44Gj44Gm44GE44G+44GZ44CC?=)
r	r
r�appendrrrr�r�r�)r6r7r��cz�utf8�g_head�cz_head�	utf8_headrr8rs           r9�test_long_nonstringz#TestLongHeaders.test_long_nonstring�s���
�
"�
"���L�!��
�\�
"���w���$��$��0�	�
�6�1�)�4��	����"��	����D�!��i����I���j���c�N��	�	�	�#��
�3�<�<�>�
�
	�	�1�8�8�r�8�"�%1�	2r;c�d�|j}tdd��}||j�d�y)N�iwasnipoop; giraffes="very-long-necked-animals"; spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"�X-Foobar-Spoink-Defrobnitr�jwasnipoop; giraffes="very-long-necked-animals";
 spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"�r	rr��r6r7rs   r9�test_long_header_encodez'TestLongHeaders.test_long_header_encode�s7��
�
"�
"���O�:�
<��	�1�8�8�:�>�	?r;c�f�|j}tddd��}||j�d�y)Nr%r&r�rrr'r(r)s   r9�<test_long_header_encode_with_tab_continuation_is_just_a_hintzLTestLongHeaders.test_long_header_encode_with_tab_continuation_is_just_a_hint�s:��
�
"�
"���O�:�#'�
)��	�1�8�8�:�>�	?r;c�f�|j}tddd��}||j�d�y)Nziwasnipoop; giraffes="very-long-necked-animals";	spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"r&rr,zjwasnipoop; giraffes="very-long-necked-animals";
	spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"r(r)s   r9�-test_long_header_encode_with_tab_continuationz=TestLongHeaders.test_long_header_encode_with_tab_continuation�s;��
�
"�
"���O�:�#'�
)��	�1�8�8�:�?�	@r;c�\�tdd�}|j|j�d�y)N�文r�=?iso-2022-jp?b?GyRCSjgbKEI=?=�rr2r��r6rs  r9�0test_header_encode_with_different_output_charsetz@TestLongHeaders.test_header_encode_with_different_output_charset�s%���5�(�#���������%E�Fr;c�~�tdjd�d�}d}|j|j�|�y)Ns6test-ja ����Ƥ��줿�᡼��ϻʲ�Ԥξ�ǧ���ԤäƤ��ޤ�rz�=?iso-2022-jp?b?dGVzdC1qYSAbJEIkWEVqOUYkNSRsJD8lYSE8JWskTztKMnE8VCROPjUbKEI=?=
 =?iso-2022-jp?b?GyRCRyckckJUJEMkRiQkJF4kORsoQg==?=)rrYr2r�)r6r�ress   r9�5test_long_header_encode_with_different_output_charsetzETestLongHeaders.test_long_header_encode_with_different_output_charset�s?���$�%+�F�8�$4�h�
@��7��	
�������S�)r;c��|j}td�}d|d<t�}t|�}|j	|�||j�d�y)Nr+r%r&z�Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Foobar-Spoink-Defrobnit: wasnipoop; giraffes="very-long-necked-animals";
 spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"

)r	rrrr�r�r
s     r9�test_header_splitterz$TestLongHeaders.test_header_splitter�sY��
�
"�
"���r�l��
H�	�'�(��j���c�N��	�	�	�#��
�3�<�<�>��	r;c�&�|j}t�}d|d<tjd�t	d�D��|d<|jd�t
�}t|�}|j|�||j�d�y)N�test@dom.ainr�c3�&K�|]	}d|z���y�w)z<%d@dom.ain>Nr�)�.0�is  r9�	<genexpr>z@TestLongHeaders.test_no_semis_header_splitter.<locals>.<genexpr>s����&M�a�~��'9�&M�s��
�
References�Testz�From: test@dom.ain
References: <0@dom.ain> <1@dom.ain> <2@dom.ain> <3@dom.ain> <4@dom.ain>
 <5@dom.ain> <6@dom.ain> <7@dom.ain> <8@dom.ain> <9@dom.ain>

Test)
r	r�SPACEr��rangerRrrr�r�r
s     r9�test_no_semis_header_splitterz-TestLongHeaders.test_no_semis_header_splittersv��
�
"�
"���i��$��F��!�J�J�&M�5��9�&M�M��L��������j���c�N��	�	�	�#��
�3�<�<�>��		r;c�`�|j}td�}||j�d�y)Nz�Subject: the first part of this is short, but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfz�Subject: the first part of this is short,
 but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfr(r)s   r9�"test_last_split_chunk_does_not_fitz2TestLongHeaders.test_last_split_chunk_does_not_fit�5��
�
"�
"����
��	�1�8�8�:�b�	cr;c�`�|j}td�}||j�d�y)Nz_, but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfz`,
 but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfr(r)s   r9�>test_splittable_leading_char_followed_by_overlong_unsplittablezNTestLongHeaders.test_splittable_leading_char_followed_by_overlong_unsplittablerIr;c�`�|j}td�}||j�d�y)Nza, , but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfzb, ,
 but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfr(r)s   r9�Gtest_multiple_splittable_leading_char_followed_by_overlong_unsplittablezWTestLongHeaders.test_multiple_splittable_leading_char_followed_by_overlong_unsplittable"rIr;c�`�|j}td�}||j�d�y)NzTthis_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself;r(r)s   r9�1test_trailing_splittable_on_overlong_unsplittablezATestLongHeaders.test_trailing_splittable_on_overlong_unsplittable+s1��
�
"�
"���*�
+��
�1�8�8�:�*�	+r;c�`�|j}td�}||j�d�y)NzW; this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; zX;
 this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; r(r)s   r9�Itest_trailing_splittable_on_overlong_unsplittable_with_leading_splittablezYTestLongHeaders.test_trailing_splittable_on_overlong_unsplittable_with_leading_splittable2s5��
�
"�
"���+�
,��	�1�8�8�:�Z�	[r;c�`�|j}td�}||j�d�y)NzpThis is a long line that has two whitespaces  in a row.  This used to cause truncation of the header when foldedzqThis is a long line that has two whitespaces  in a row.  This used to cause
 truncation of the header when foldedr(r)s   r9�5test_long_header_with_multiple_sequential_split_charszETestLongHeaders.test_long_header_with_multiple_sequential_split_chars;s3��
�
"�
"���F�
G��
�1�8�8�:�)�	*r;c�`�|j}td�}||j�d�y)N�Kthisverylongheaderhas;semicolons;and,commas,butthey;arenotlegal;fold,pointsr(r)s   r9�:test_splitter_split_on_punctuation_only_if_fws_with_headerzJTestLongHeaders.test_splitter_split_on_punctuation_only_if_fws_with_headerCs1��
�
"�
"���+�
,��
�1�8�8�:�2�	3r;c�`�|j}td�}||j�d�y)Nz�this is a  test where we need to have more than one line before; our final line that is just too big to fit;; this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself;z�this is a  test where we need to have more than one line before;
 our final line that is just too big to fit;;
 this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself;r(r)s   r9�Dtest_leading_splittable_in_the_middle_just_before_overlong_last_partzTTestLongHeaders.test_leading_splittable_in_the_middle_just_before_overlong_last_partJs5��
�
"�
"���*�
+��	�1�8�8�:�Y�	Zr;c�`�|j}td�}||j�d�y)NzTthis_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself r(r)s   r9�/test_overlong_last_part_followed_by_split_pointz?TestLongHeaders.test_overlong_last_part_followed_by_split_pointUs1��
�
"�
"���*�
+��
�1�8�8�:�=�	>r;c�`�|j}td�}||j�d�y)Nz�this_is_a__test_where_we_need_to_have_more_than_one_line_before_our_final_line_; ; this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; z�this_is_a__test_where_we_need_to_have_more_than_one_line_before_our_final_line_;
 ;
 this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; r(r)s   r9�@test_multiline_with_overlong_parts_separated_by_two_split_pointszPTestLongHeaders.test_multiline_with_overlong_parts_separated_by_two_split_points\�5��
�
"�
"���+�
,��	�1�8�8�:�Z�	[r;c�`�|j}td�}||j�d�y)Nz�this is a test where we need to have more than one line before our final line; ; this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; z�this is a test where we need to have more than one line before our final line;
 ;
 this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; r(r)s   r9�>test_multiline_with_overlong_last_part_followed_by_split_pointzNTestLongHeaders.test_multiline_with_overlong_last_part_followed_by_split_pointgr]r;c��|j}t�}d|d<tjdgdz�|d<|j	d�t�}t
|�}|j|�||j�d�y)Nr<r�z<foo@dom.ain>  rArBrCz�From: test@dom.ain
References: <foo@dom.ain>   <foo@dom.ain>   <foo@dom.ain>   <foo@dom.ain>
   <foo@dom.ain>   <foo@dom.ain>   <foo@dom.ain>   <foo@dom.ain>
   <foo@dom.ain>   <foo@dom.ain>  

Test�	r	rrDr�rRrrr�r�r
s     r9�%test_long_header_with_whitespace_runsz5TestLongHeaders.test_long_header_with_whitespace_runsrsu��
�
"�
"���i��$��F��!�J�J�(9�':�R�'?�@��L��������j���c�N��	�	�	�#��
�3�<�<�>��		r;c��|j}t�}d|d<tjdgdz�dz|d<|j	d�t�}t
|�}|j|�||j�d�y)	Nr<r�z
<foo@dom.ain>rAz; abcrBrCz�From: test@dom.ain
References: <foo@dom.ain> <foo@dom.ain> <foo@dom.ain> <foo@dom.ain>
 <foo@dom.ain> <foo@dom.ain> <foo@dom.ain> <foo@dom.ain> <foo@dom.ain>
 <foo@dom.ain>; abc

Testrar
s     r9�'test_long_run_with_semi_header_splitterz7TestLongHeaders.test_long_run_with_semi_header_splitter�sy��
�
"�
"���i��$��F��!�J�J��'8�2�'=�>��H��L��������j���c�N��	�	�	�#��
�3�<�<�>��		r;c���|j}t�}d|d<d|d<|jd�t�}t	|�}|j|�||j
�d�y)Nr<r�rUrBrCzrFrom: test@dom.ain
References: 
 thisverylongheaderhas;semicolons;and,commas,butthey;arenotlegal;fold,points

Test)r	rrRrrr�r�r
s     r9�.test_splitter_split_on_punctuation_only_if_fwsz>TestLongHeaders.test_splitter_split_on_punctuation_only_if_fws�se��
�
"�
"���i��$��F��+��L��������j���c�N��	�	�	�#��
�3�<�<�>��		r;c��|j}d}t|�}||j�d�td�}||j�d�y)Nz\References: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz]References:
 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx�Pxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxr(rs    r9�test_no_split_long_headerz)TestLongHeaders.test_no_split_long_header�sQ��
�
"�
"��(���4�L��	�1�8�8�:�U�	V�
�8���
�1�8�8�:�i�jr;c�h�|j}d}t|d��}||j�d�y)NaWfrom babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
	from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
	from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
rra_from babylon.socal-raves.org (localhost [127.0.0.1]);
 by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
 for <mailman-admin@babylon.socal-raves.org>;
 Sat, 2 Feb 2002 17:00:06 -0800 (PST)
	from babylon.socal-raves.org (localhost [127.0.0.1]);
 by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
 for <mailman-admin@babylon.socal-raves.org>;
 Sat, 2 Feb 2002 17:00:06 -0800 (PST)
	from babylon.socal-raves.org (localhost [127.0.0.1]);
 by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
 for <mailman-admin@babylon.socal-raves.org>;
 Sat, 2 Feb 2002 17:00:06 -0800 (PST)r(rs    r9�"test_splitting_multiple_long_linesz2TestLongHeaders.test_splitting_multiple_long_lines�s7��
�
"�
"����

�4��.��
�1�8�8�:�)�	*r;c�l�|j}d}t|ddd��}||j�d�y)Nz�from modemcable093.139-201-24.que.mc.videotron.ca ([24.201.139.93] helo=cthulhu.gerg.ca)
	by kronos.mems-exchange.org with esmtp (Exim 4.05)
	id 17k4h5-00034i-00
	for test@mems-exchange.org; Wed, 28 Aug 2002 11:25:20 -0400�N�Receivedr)rrrz�from modemcable093.139-201-24.que.mc.videotron.ca ([24.201.139.93]
 helo=cthulhu.gerg.ca)
	by kronos.mems-exchange.org with esmtp (Exim 4.05)
	id 17k4h5-00034i-00
	for test@mems-exchange.org; Wed, 28 Aug 2002 11:25:20 -0400r(rs    r9�&test_splitting_first_line_only_is_longz6TestLongHeaders.test_splitting_first_line_only_is_long�sA��
�
"�
"��A��

�4�B�J�#'�
)��
�1�8�8�:�A�	Br;c��|j}t�}tddd��}|jd�||j	d��d�||d<||jd�	�d
�||jd�	�d�y)
NzBritische Regierung gibtr=r�ru-grünes Licht für Offshore-Windkraftprojekter�rzl=?iso-8859-1?q?Britische_Regierung_gibt_gr=FCnes_Licht_f=FCr_Offs?=
 =?iso-8859-1?q?hore-Windkraftprojekte?=��maxheaderlenzwSubject: =?iso-8859-1?q?Britische_Regierung_gibt_gr=FCnes_Licht_f=FCr_Offs?=
 =?iso-8859-1?q?hore-Windkraftprojekte?=

rzdSubject: =?iso-8859-1?q?Britische_Regierung_gibt_gr=FCnes_Licht_f=FCr_Offshore-Windkraftprojekte?=

)r	rrrr�r�)r6r7r8rs    r9�test_long_8bit_headerz%TestLongHeaders.test_long_8bit_header�s���
�
"�
"���i���-�|� )�
+��	���D�E�
�1�8�8�r�8�"�%,�	-���I��
�3�=�=�b�=�)�,�	�
	�3�=�=�a�=�(�+�	r;c���|j}t�}d}||d<||jd��d�t�}t|d��|d<||jd��d�y)NuhBritische Regierung gibt grünes Licht für Offshore-Windkraftprojekte <a-very-long-address@example.com>zReply-Tormrqz�Reply-To: =?utf-8?q?Britische_Regierung_gibt_gr=C3=BCnes_Licht_f=C3=BCr_Offs?=
 =?utf-8?q?hore-Windkraftprojekte_=3Ca-very-long-address=40example=2Ecom=3E?=

r)r	rr�r)r6r7r8�
header_strings    r9� test_long_8bit_header_no_charsetz0TestLongHeaders.test_long_8bit_header_no_charset�sv��
�
"�
"���i��=�
�(��J��
�3�=�=�b�=�)�,�	�
�i�� ��-7�9��J��
�3�=�=�b�=�)�,�	r;c�p�|j}d}t�}||d<||jd��d�y)Nz�"Someone Test #A" <someone@eecs.umich.edu>,<someone@eecs.umich.edu>, "Someone Test #B" <someone@umich.edu>, "Someone Test #C" <someone@eecs.umich.edu>, "Someone Test #D" <someone@eecs.umich.edu>r�rmrqz�To: "Someone Test #A" <someone@eecs.umich.edu>,<someone@eecs.umich.edu>,
 "Someone Test #B" <someone@umich.edu>,
 "Someone Test #C" <someone@eecs.umich.edu>,
 "Someone Test #D" <someone@eecs.umich.edu>

)r	rr�)r6r7r�r8s    r9�test_long_to_headerz#TestLongHeaders.test_long_to_headers@��
�
"�
"��;��
�i����D�	�
�3�=�=�b�=�)�,�	r;c��|j}d}t|�}|jd�||jd��d�y)NzIThis is an example of string which has almost the limit of header length.zAdd another line.r�rz\This is an example of string which has almost the limit of header length.
 Add another line.�r	rrr��r6r7r�rs    r9�test_long_line_after_appendz+TestLongHeaders.test_long_line_after_appendsB��
�
"�
"��W���1�I��	���$�%�
�1�8�8�r�8�"�%�	r;c��|j}d}t|�}|jd�||j�d�y)NzThis is a shorter line.z!Add another sentence. (Surprise?)z9This is a shorter line. Add another sentence. (Surprise?)rzr{s    r9�test_shorter_line_with_appendz-TestLongHeaders.test_shorter_line_with_appends<��
�
"�
"��%���1�I��	���4�5�
�1�8�8�:�F�	Hr;c�r�|j}d}d}t|d|��}||jd��d�y)Nz!X-Very-Very-Very-Long-Header-Nameu�Die Mieter treten hier ein werden mit einem Foerderband komfortabel den Korridor entlang, an südlündischen Wandgemälden vorbei, gegen die rotierenden Klingen befördert. r=rr�ra=?iso-8859-1?q?Die_Mieter_treten_hier_e?=
 =?iso-8859-1?q?in_werden_mit_einem_Foerderband_komfortabel_den_Korridor_e?=
 =?iso-8859-1?q?ntlang=2C_an_s=FCdl=FCndischen_Wandgem=E4lden_vorbei=2C_ge?=
 =?iso-8859-1?q?gen_die_rotierenden_Klingen_bef=F6rdert=2E_?=r()r6r7�fn�gsrs     r9�test_long_field_namez$TestLongHeaders.test_long_field_name#sE��
�
"�
"��
0����
�2�|��4��
�1�8�8�r�8�"�%A�	Br;c��d}t�}t|d��|d<||d<|j|jd��d�y)	Nz�from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by hrothgar.la.mastaler.com (tmda-ofmipd) with ESMTP; Wed, 05 Mar 2003 18:10:18 -0700rr�
Received-1�
Received-2rmrqa1Received-1: from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by
 hrothgar.la.mastaler.com (tmda-ofmipd) with ESMTP;
 Wed, 05 Mar 2003 18:10:18 -0700
Received-2: from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by
 hrothgar.la.mastaler.com (tmda-ofmipd) with ESMTP;
 Wed, 05 Mar 2003 18:10:18 -0700

�rrr	r��r6rr8s   r9�test_long_received_headerz)TestLongHeaders.test_long_received_header2sM��/���i��"�1�d�;��L����L�����c�m�m��m�<�?�	r;c��d}t�}t|dd��|d<||d<|j|jd��d�y)	Nz�<15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> (David Bremner's message of "Thu, 6 Mar 2003 13:58:21 +0100")r�rr,r�rmrqa#Received-1: 
 <15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> (David
 Bremner's message of "Thu, 6 Mar 2003 13:58:21 +0100")
Received-2: 
 <15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> (David
 Bremner's message of "Thu, 6 Mar 2003 13:58:21 +0100")

r�r�s   r9�test_string_headerinst_eqz)TestLongHeaders.test_string_headerinst_eqDsR��1���i��"�1�,�37�9��L����L�����c�m�m��m�<�?�	r;c��|j}t�}d}||d<t|d��|d<d|z|d<||jd��d	�y)
Nz�iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzpzFace-1zFace-2rr,zFace-3rmrqa�Face-1: 
 iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp
Face-2: 
 iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp
Face-3: 
 iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp

�r	rrr�)r6r7r8�ts    r9�-test_long_unbreakable_lines_with_continuationz=TestLongHeaders.test_long_unbreakable_lines_with_continuationWs`��
�
"�
"���i��
M����H�
��q�h�7��H�
��a���H�
�	�3�=�=�b�=�)�,�	r;c�|�|j}d}tj|�}||jd��d�y)Nz�Received: from siimage.com ([172.25.1.3]) by zima.siliconimage.com with Microsoft SMTPSVC(5.0.2195.4905); Wed, 16 Oct 2002 07:41:11 -0700rmrqz�Received: from siimage.com ([172.25.1.3]) by zima.siliconimage.com with
 Microsoft SMTPSVC(5.0.2195.4905); Wed, 16 Oct 2002 07:41:11 -0700

)r	r�r�r��r6r7r�r8s    r9�"test_another_long_multiline_headerz2TestLongHeaders.test_another_long_multiline_headeros@��
�
"�
"��/���'�'��*��
�3�=�=�b�=�)�,�	r;c��|j}d}t�}||d<t|d��|d<||jd��d�y)Nz�List-Unsubscribe: <http://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,        <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>�Listrrmrqa_List: List-Unsubscribe:
 <http://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,
        <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>
List: List-Unsubscribe:
 <http://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,
        <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>

r�)r6r7rr8s    r9�%test_long_lines_with_different_headerz5TestLongHeaders.test_long_lines_with_different_header|sP��
�
"�
"��%���i����F���Q�F�3��F��
�3�=�=�b�=�)�,�	r;c��ttjd�dd��}|j|j	�dztjd�dz�y)Nz�            We're going to pretend this header is in a non-ascii character set
            	to see if line wrapping with encoded words and embedded
               folding white space worksrVrC)rArr*z�            =?utf-8?q?We=27re_going_to_pretend_this_header_is_in_a_non-ascii_chara?=
             =?utf-8?q?cter_set?=
             =?utf-8?q?_to_see_if_line_wrapping_with_encoded_words_and_embedded?=
             =?utf-8?q?_folding_white_space_works?=)rr�r�r2r�r4s  r9�*test_long_rfc2047_header_with_embedded_fwsz:TestLongHeaders.test_long_rfc2047_header_with_embedded_fws�sZ���8�?�?�$,�-�#�%�
'��	
�������D��(�/�/�;7�+8�9=�	+=�	>r;)+r�r�r��maxDiffrrr#r*r-r/r5r8r:rFrHrKrMrOrQrSrVrXrZr\r_rbrdrfrirkrorsrvrxr|r~r�r�r�r�r�r�r�r�r;r9rrbs����G��(�"42�l?�?�@�G�*��(	� c�c�c�+�[�*�3�	Z�>�	[�	[�	�"	�"	�$
k�*�,B� �(�*�"�H�
B��$�&�0��&>r;rc�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�TestFromManglingc�v�t�|_d|jd<|jjd�y)Nzaaa@bbb.orgr�z(From the desk of A.A.A.:
Blah blah blah
)rr8rR�r6s r9�setUpzTestFromMangling.setUp�s0���9���(������������	r;c��t�}t|d��}|j|j�|j	|j�d�y)NT��mangle_from_z<From: aaa@bbb.org

>From the desk of A.A.A.:
Blah blah blah
�rrr�r8r2r��r6r�r�s   r9�test_mangled_fromz"TestFromMangling.test_mangled_from�s@���J���a�d�+��	�	�	�$�(�(���������(�	r;c��t�}t|d��}|j|j�|j	|j�d�y)NFr�z;From: aaa@bbb.org

From the desk of A.A.A.:
Blah blah blah
r�r�s   r9�test_dont_mangle_fromz&TestFromMangling.test_dont_mangle_from�s@���J���a�e�,��	�	�	�$�(�(���������(�	r;c
�\�t�}t|d��}tjt	j
d��}|j
|�|jt|j�jd�D�cgc]}|jd�rd��c}�d�ycc}w)NTr�a)            From: foo@bar.com
            Mime-Version: 1.0
            Content-Type: multipart/mixed; boundary=XXX

            From somewhere unknown

            --XXX
            Content-Type: text/plain

            foo

            --XXX--

            From somewhere unknowable
            r*z>From r|r�)rrr�r�r�r�r�r2r�r�r�r�)r6r�r�r8r�s     r9�'test_mangle_from_in_preamble_and_epilogz8TestFromMangling.test_mangle_from_in_preamble_and_epilog�s����J���a�d�+���'�'����9�)��� 	
�	�	�#����������);�);�D�)A�=�A�%&�\�\�(�%;� �=�>�?@�	B��=s�B)c��tjd�jd�}tj|dz�}t�}t
|d��}|j|�|j|j�|dz�y)Nz�            Content-Type: text/plain; charset="utf-8"
            MIME-Version: 1.0
            Content-Transfer-Encoding: 8bit
            From: aaa@bbb.org

        rVsFrom Rölli
Tr�s
>From Rölli
)
r�r�r�r�r�rr
r�r2r�)r6r�r8�br�s     r9� test_mangled_from_with_bad_bytesz1TestFromMangling.test_mangled_from_with_bad_bytes�su�����"�
��V�G�_�
	��&�&�v�0F�'F�G���I���1�4�0��	�	�	�#���������v�0G�'G�Hr;c�v�tjd�jd�}tj|�}y)Nu�            From: aperson@example.com
            Content-Type: multipart/mixed; boundary="1"
            Content-Transfer-Encoding: È
        rV)r�r�r�r�r�)r6r�r8s   r9�$test_multipart_with_bad_bytes_in_ctez5TestFromMangling.test_multipart_with_bad_bytes_in_cte�s5�����"�
��V�G�_�		�
�&�&�v�.�r;N)	r�r�r�r�r�r�r�r�r�r�r;r9r�r��s"���	�	�B�.I�/r;r�c�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�
TestMIMEAudioc��td|��d�5}|j�|_ddd�t|j�|_y#1swY�$xYw)Nzsndhdr.r�)r'r��
_audiodatar�_au�r6�extr�s   r9�_make_audiozTestMIMEAudio._make_audio�sF��
���u�o�t�
,�	(�� �g�g�i�D�O�	(��T�_�_�-���	(�	(���A	�	Ac���ddddd�j�D]I\}}|j|�|�|n|}|j|jj	�d|����Ky)Nzx-aiffzx-wav�basic)�aifc�aiff�wav�auzaudio/)r�r�r2r�rH�r6r��subtypes   r9�test_guess_minor_typez#TestMIMEAudio.test_guess_minor_type�sm������	
�
�%�'�	N�L�C��
���S�!�$�_�c�'�G����T�X�X�6�6�8�F�7�)�:L�M�	Nr;c���|jd�|jj�}|jt	j
t
|d��|j�y)Nr�r�)r�r�rZr2rW�decodebytesr�r��r6�payloads  r9�
test_encodingzTestMIMEAudio.test_encoding�sK��������(�(�&�&�(������+�+�E�'�7�,C�D����	*r;c��|jd�t|jd�}|j|j	�d�y)Nr��fishz
audio/fish)r�rr�r2rH)r6r�s  r9�test_checkSetMinorz TestMIMEAudio.test_checkSetMinors9�������
�t����
/������,�,�.��=r;c��|jd�|j}|jjddd��||jdd�||jj	d��d	d
g�||jjdd��d�g}||jjdd��d�|j
|jjd
|d��|�|j
|jjd|�|�|j
|jjd|d��|�y)Nr�r>r?�	sndhdr.aurArCz attachment; filename="sndhdr.au"r�r?r+)rBr�rBr+r���failobjr�rK)r�r2r�rErrI�assertIs�r6r7�missings   r9�test_add_headerzTestMIMEAudio.test_add_header
s8�������
�
�
�������1�<�%0�	�	2�
�4�8�8�)�*�-�	/�
�4�8�8���&;��<�� 9�:�	<�
�4�8�8���j�1F��G��	���
�4�8�8���l�3H��I�2�N��
�
�d�h�h�(�(��7�(�)�*�+2�	4�	
�
�
�d�h�h�(�(��7�;�W�E��
�
�d�h�h�(�(��w�08�)�:�;B�	Dr;N)r�r�r�r�r�r�r�r�r�r;r9r�r��s��.�
	N�*�>�
Dr;r�c�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�
TestMIMEImagec��td|��d�5}|j�|_ddd�t|j�|_y#1swY�$xYw)Nzpython.r�)r'r��_imgdatar�_imr�s   r9�_make_imagezTestMIMEImage._make_image#sF��
���u�o�t�
,�	&���G�G�I�D�M�	&��T�]�]�+���	&�	&�r�c���dddddddddddddd�
j�D]I\}}|j|�|�|n|}|j|jj	�d|����Ky)N�jpeg�rast�rgb)
�bmp�exr�gif�jpg�pbm�pgm�png�ppm�ras�sgi�tiff�webp�xbmzimage/)r�r�r2r�rHr�s   r9r�z#TestMIMEImage.test_guess_minor_type(s����������������
��%�'�	N�L�C��
���S�!�$�_�c�'�G����T�X�X�6�6�8�F�7�)�:L�M�#	Nr;c���|jd�|jj�}|jt	j
t
|d��|j�y)Nr�r�)r�r�rZr2rWr�r�r�r�s  r9r�zTestMIMEImage.test_encoding<sK��������(�(�&�&�(������+�+�E�'�7�,C�D����	(r;c��|jd�t|jd�}|j|j	�d�y)Nr�r�z
image/fish)r�rr�r2rH)r6�ims  r9r�z TestMIMEImage.test_checkSetMinorBs9�������
�t�}�}�f�
-������,�,�.��=r;c��|jd�|j}|jjddd��||jdd�||jj	d��d	d
g�||jjdd��d�g}||jjdd��d�|j
|jjd
|d��|�|j
|jjd|�|�|j
|jjd|d��|�y)Nr�r>r?r}rArCz%attachment; filename="dingusfish.gif"rr�)rBr}rBr+r�r�rK)r�r2r�rErrIr�r�s   r9r�zTestMIMEImage.test_add_headerGs:�������
�
�
�������1�<�%5�	�	7�
�4�8�8�)�*�2�	4�
�4�8�8���&;��<�� >�?�	A�
�4�8�8���j�1F��G��	���
�4�8�8���l�3H��I�2�N��
�
�d�h�h�(�(���0E�)�G�HO�	Q�	
�
�
�d�h�h�(�(��7�;�W�E��
�
�d�h�h�(�(��w�08�)�:�;B�	Dr;N)r�r�r�r�r�r�r�r�r�r;r9r�r�"s��,�
N�((�>�
Dr;r�c�6�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	y)	�TestMIMEApplicationc�x�|j}td�}||j�d�||dd�y)N�������rSrBrW)r2rrHr5s   r9�test_headersz TestMIMEApplication.test_headers^s<��
�
�
���9�:��
�3���!�#=�>�
�3�*�+�X�6r;c��|j}d}t|�}||j�j�d�||jd��|�y)Nr�z+vv8/f7/TrX)r2rrZ�strip)r6r7�	bytesdatar8s    r9�	test_bodyzTestMIMEApplication.test_bodydsK��
�
�
��/�	��i�(��
�3�?�?��"�"�$�j�1�
�3�?�?�$�?�'��3r;c�`�d}t|tj��}|j|j	�dt|�z�|j|j	d��|�|j|dd�t
�}t|�}|j|�|j�}tj|�}|j|j	�dt|�z�|j|j	d��|�|j|dd�y)Nr���_encoder��TrXrEr`)rr�encode_7or8bitr2rZr�rr
r�r�r�r��r6r�r8r�r��wireform�msg2s       r9�$test_binary_body_with_encode_7or8bitz8TestMIMEApplication.test_binary_body_with_encode_7or8bitls���/�	��i�(�2I�2I�J��������*�H�s�9�~�,E�F���������5�y�A�����8�9�6�B��I���1���	�	�	�#���:�:�<���'�'��1��������*�H�s�9�~�,E�F�����)�)��)�6�	�B�����9�:�F�Cr;c��d}t|tj��}|j|j	�dt|�z�|j|j	d��|�t
�}t|�}|j|�|j�}tj|�}|j|j	�dt|�z�|j|j	d��|�y)Nr�r�r�TrX)rr�encode_noopr2rZr�rr
r�r�r�r�r�s       r9�!test_binary_body_with_encode_noopz5TestMIMEApplication.test_binary_body_with_encode_noop}s���0�	��i�(�2F�2F�G��������*�H�s�9�~�,E�F���������5�y�A��I���1���	�	�	�#���:�:�<���'�'��1��������*�H�s�9�~�,E�F�����)�)��)�6�	�Br;c�\�d}t|tj��}|j|j	d��|�t�}t
|�}|j|�|j�}tj|�}|j|j	d��|�y)Ns������r�TrX)rrr�r2rZrr
r�r�r�r�r�s       r9�0test_binary_body_with_unicode_linend_encode_noopzDTestMIMEApplication.test_binary_body_with_unicode_linend_encode_noop�s���3�	��i�(�2F�2F�G����������5�y�A��I���1���	�	�	�#���:�:�<���'�'��1������)�)��)�6�	�Br;c�0�d}t|tj��}|j|j	�d�|j|j	d��|�|j|dd�t�}t
|�}|j|�|j�}tj|�}|j|j	�d�|j|j	d��|�|j|dd�y)Ns������ r�z=FA=FB=FC=FD=FE=FF=20TrXrErC)rr�
encode_quoprir2rZrr
r�r�r�r�r�s       r9�#test_binary_body_with_encode_quopriz7TestMIMEApplication.test_binary_body_with_encode_quopri�s���0�	��i�(�2H�2H�I��������*�,C�D���������5�y�A�����8�9�;M�N��I���1���	�	�	�#���:�:�<���'�'��1��������*�,C�D�����)�)��)�6�	�B�����9�:�<N�Or;c���d}t|tj��}|j|j	�d�|j|j	d��|�t�}t
|�}|j|�|j�}tj|�}|j|j	�d�|j|j	d��|�y)Nr�r�z	+vv8/f7/
TrX)rr�
encode_base64r2rZrr
r�r�r�r�r�s       r9�#test_binary_body_with_encode_base64z7TestMIMEApplication.test_binary_body_with_encode_base64�s���/�	��i�(�2H�2H�I��������*�L�9���������5�y�A��I���1���	�	�	�#���:�:�<���'�'��1��������*�L�9�����)�)��)�6�	�Br;N)
r�r�r�r�r�r�r�rrrr�r;r9r�r�]s*��7�4�D�"C�"
C�P� Cr;r�c�f�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	e
jd�d	��Zy
)�TestMIMETextc�$�td�|_y�N�hello there)r�_msgr�s r9r�zTestMIMEText.setUp�s���]�+��	r;c�Z�|j}||jj�d�||jjd�d�g}|j	|jjd|�|�|j	|jjd|d��|�y)Nr?rArNrKr)r2rrHrIr�r�s   r9�
test_typeszTestMIMEText.test_types�s���
�
�
��
�4�9�9�%�%�'��6�
�4�9�9���y�)�:�6����
�
�d�i�i�)�)�(�G�<�g�F��
�
�d�i�i�)�)�)�W�X�)�N��	r;c��|j|jj�d�|j|jj	��yr
)r2rrZ�assertFalse�is_multipartr�s r9�test_payloadzTestMIMEText.test_payload�s:��������.�.�0�-�@�������/�/�1�2r;c�V�|j}tdd��}||j�jd�||dd�t	d�}d|_td|��}||j�jd�||dd�||j
�d�y)NrrNr�r@rOrVr�)r2rrFrJr
rarZrKs    r9�test_charsetzTestMIMEText.test_charset�s���
�
�
���}�z�:��
�3�?�?��*�*�J�7�
�3�~�� @�A��'�"�� $����}�w�7��
�3�?�?��*�*�G�4�
�3�~�� =�>�
�3�?�?��m�,r;c��|j}tdd��}||j�jd�||dd�y)NrrNr�r@rO)r2rrFrJr5s   r9�test_7bit_inputzTestMIMEText.test_7bit_input�s@��
�
�
���}�z�:��
�3�?�?��*�*�J�7�
�3�~�� @�Ar;c��|j}td�}||j�d�||dd�|jd|j	��y)NrrNr@rO)r2rrFr�r�r5s   r9�test_7bit_input_no_charsetz'TestMIMEText.test_7bit_input_no_charset�sL��
�
�
���}�%��
�3�?�?��j�)�
�3�~�� @�A��
�
�m�S�]�]�_�5r;c���d}|j}t|d��}||j�jd�||dd�||j	d��|jd��y)N�кирилицаrVr�r@r�TrX)r2rrF�output_charsetrZr�)r6�teststrr7r8s    r9�test_utf8_inputzTestMIMEText.test_utf8_input�sc��D��
�
�
���w��1��
�3�?�?��+�+�W�5�
�3�~�� =�>�
�3�?�?�$�?�'�����)@�Ar;zBcan't fix because of backward compat in email5, will fix in email6c�>�d}|jtt|�y)Nr)r��UnicodeEncodeErrorr)r6rs  r9�test_utf8_input_no_charsetz'TestMIMEText.test_utf8_input_no_charset�s��E�����,�h��@r;N)
r�r�r�r�rrrrrr�unittest�skipr r�r;r9rr�sM��,��3�-�B�6�B��X�]�]���A��Ar;rc��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�
TestMultipartc�n�tdd�5}|j�}ddd�tddd��}td��}|j	d	d
d��td�}|j
|�|j
|�d
|d<d|d<d|d<d}tj|�}|ddk(rtj}ntj}|dkDrd}	nd}	d|	|dzfz}
tjdtj|��|
z|d<||_||_
||_y#1swY��xYw)Nr�r��	multipart�mixedr��rr})rrCr?rAz$Hi there,

This is the dingus fish.
zBarry <barry@digicool.com>r�z)Dingus Lovers <cravindogs@cravindogs.com>r�zHere is your dingus fishr�g�4F�cp�A���r�-�+z %s%04d�$z%a, %d %b %Y %H:%M:%S�Date)r'r�rrrErrn�time�	localtime�timezone�altzone�strftimerr��_txt)r6r�r\�	containerr��intro�now�	timetuple�tzsecs�sign�tzoffsets           r9r�zTestMultipart.setUp�sE��
�l�D�
)�	�R��7�7�9�D�	��[�'�J�G�	��$�%5�6��
���.��"2�	�	4�����
	����������8�	�&��E�	�$��9�	�)�� ���N�N�3�'�	��R�=�A���]�]�F��\�\�F��A�:��D��D���f�r�k�2�2�� �M�M�#��N�N�3��!�#+�,�	�&����	������	�C	�	�s�D*�*D4c��|j}|j}|j}|j|j	��||j�d�|t
|j��d�|t|jd�|jd�}|jd�}|j||j�|j||j�||j�||g�|j|j	��|j|j	��y)Nrkr�rr|)
r2r�rr�rrHr�rZ�
IndexErrorr�r3r�r)r6r7�raisesr��m0�m1s      r9�test_hierarchyzTestMultipart.test_hierarchys���
�
�
���"�"���I�I��������(�)�
�1����!2�3�
�3�q�}�}����#��z�1�=�=�!�,�
�]�]�1�
��
�]�]�1�
���
�
�b�$�)�)�$��
�
�b�$�(�(�#�
�1�=�=�?�R��H�%�������*�+�������*�+r;c�z�d}t�j|�}|j||j��y)Nz�Content-Type: multipart/mixed; boundary="BOUNDARY"
MIME-Version: 1.0
Subject: A subject
To: aperson@dom.ain
From: bperson@dom.ain


--BOUNDARY


--BOUNDARY--
)rr�r	r�)r6r�r8s   r9�test_empty_multipart_idempotentz-TestMultipart.test_empty_multipart_idempotent,s3�����h����%�����d�C�M�M�O�4r;c��tdd�}d|d<d|d<d|d<|jd	�|j|j�d
�y)Nr&r'�	A subjectr��aperson@dom.ainr��bperson@dom.ainr�r�z�Content-Type: multipart/mixed; boundary="BOUNDARY"
MIME-Version: 1.0
Subject: A subject
To: aperson@dom.ain
From: bperson@dom.ain

--BOUNDARY

--BOUNDARY--
)rr�r	r��r6�outers  r9�/test_no_parts_in_a_multipart_with_none_epiloguez=TestMultipart.test_no_parts_in_a_multipart_with_none_epilogue=sT����g�.��&��i��'��d��)��f�
�
���:�&����e�o�o�/�
2�
	r;c��tdd�}d|d<d|d<d|d<d	|_d	|_|jd
�|j	|j�d�y)Nr&r'rDr�rEr�rFr�r+r�z�Content-Type: multipart/mixed; boundary="BOUNDARY"
MIME-Version: 1.0
Subject: A subject
To: aperson@dom.ain
From: bperson@dom.ain


--BOUNDARY

--BOUNDARY--
)r�preamble�epiloguer�r	r�rGs  r9�0test_no_parts_in_a_multipart_with_empty_epiloguez>TestMultipart.test_no_parts_in_a_multipart_with_empty_epilogueOsb����g�.��&��i��'��d��)��f�
�������
���:�&����e�o�o�/�2�	r;c���|j}tdd�}d|d<d|d<d|d<|jd	�td
�}|j	|�||j�d�y)Nr&r'rDr�rEr�rFr�r�r��Content-Type: multipart/mixed; boundary="BOUNDARY"
MIME-Version: 1.0
Subject: A subject
To: aperson@dom.ain
From: bperson@dom.ain

--BOUNDARY
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

hello world
--BOUNDARY--
)r	rr�rrnr��r6r7rHr8s    r9�test_one_part_in_a_multipartz*TestMultipart.test_one_part_in_a_multipartdso��
�
"�
"����g�.��&��i��'��d��)��f�
�
���:�&��}�%��
���S��
�5�?�?���	r;c���|j}tdd�}d|d<d|d<d|d<d	|_td
�}|j	|�|jd�||j
�d�y)
Nr&r'rDr�rEr�rFr�r+r�r�aContent-Type: multipart/mixed; boundary="BOUNDARY"
MIME-Version: 1.0
Subject: A subject
To: aperson@dom.ain
From: bperson@dom.ain


--BOUNDARY
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

hello world
--BOUNDARY--
�r	rrKrrnr�r�rPs    r9�1test_seq_parts_in_a_multipart_with_empty_preamblez?TestMultipart.test_seq_parts_in_a_multipart_with_empty_preamble}sv��
�
"�
"����g�.��&��i��'��d��)��f�
�����}�%��
���S��
���:�&�
�5�?�?���	r;c���|j}tdd�}d|d<d|d<d|d<d|_td	�}|j	|�|jd
�||j
�d�y�Nr&r'rDr�rEr�rFr�r�r�rOrSrPs    r9�0test_seq_parts_in_a_multipart_with_none_preamblez>TestMultipart.test_seq_parts_in_a_multipart_with_none_preamble��v��
�
"�
"����g�.��&��i��'��d��)��f�
�����}�%��
���S��
���:�&�
�5�?�?���	r;c���|j}tdd�}d|d<d|d<d|d<d|_td	�}|j	|�|jd
�||j
�d�yrV�r	rrLrrnr�r�rPs    r9�0test_seq_parts_in_a_multipart_with_none_epiloguez>TestMultipart.test_seq_parts_in_a_multipart_with_none_epilogue�rXr;c���|j}tdd�}d|d<d|d<d|d<d	|_td
�}|j	|�|jd�||j
�d�y)
Nr&r'rDr�rEr�rFr�r+r�r�rOrZrPs    r9�1test_seq_parts_in_a_multipart_with_empty_epiloguez?TestMultipart.test_seq_parts_in_a_multipart_with_empty_epilogue�sv��
�
"�
"����g�.��&��i��'��d��)��f�
�����}�%��
���S��
���:�&�
�5�?�?���	r;c���|j}tdd�}d|d<d|d<d|d<d	|_td
�}|j	|�|jd�||j
�d�y)
Nr&r'rDr�rEr�rFr�r*r�r�aContent-Type: multipart/mixed; boundary="BOUNDARY"
MIME-Version: 1.0
Subject: A subject
To: aperson@dom.ain
From: bperson@dom.ain

--BOUNDARY
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

hello world
--BOUNDARY--

rZrPs    r9�.test_seq_parts_in_a_multipart_with_nl_epiloguez<TestMultipart.test_seq_parts_in_a_multipart_with_nl_epilogue�sv��
�
"�
"����g�.��&��i��'��d��)��f�
�����}�%��
���S��
���:�&�
�5�?�?���	r;c��|j}|jd�}|t|j��d�|jd�}||j	�d�|t|j��d�|j�D]a}||j	�d�|t|j��d�|jd�}||j	�d��cy)N�
msg_36.txtr�r|zmultipart/alternativezmessage/external-bodyrr?)r2r3r�rZrH)r6r7r8�msg1r��
subsubparts      r9�test_message_external_bodyz(TestMultipart.test_message_external_bodys���
�
�
���l�l�<�(��
�3�s��� �!�1�%����q�!��
�4� � �"�$;�<�
�3�t���!�"�A�&��'�'�)�	<�G��w�'�'�)�+B�C��s�7�&�&�(�)�1�-� �,�,�Q�/�J��z�*�*�,�l�;�		<r;c�x�|jd�}|jt|j��d�y)Nz
msg_37.txtr�)r3r2r�rZrhs  r9�test_double_boundaryz"TestMultipart.test_double_boundarys.���l�l�<�(������S�_�_�.�/��3r;c��|j}|jd�}t�}tj||�||j�d�y)Nz
msg_38.txtz�multipart/mixed
    multipart/mixed
        multipart/alternative
            text/plain
        text/plain
    text/plain
    text/plain
�r	r3rr!�
_structurer��r6r7r8rs    r9�)test_nested_inner_contains_outer_boundaryz7TestMultipart.test_nested_inner_contains_outer_boundarysI��
�
"�
"��
�l�l�<�(���j�����S�#�&�
�3�<�<�>��	r;c��|j}|jd�}t�}tj||�||j�d�y)Nz
msg_39.txtz�multipart/mixed
    multipart/mixed
        multipart/alternative
        application/octet-stream
        application/octet-stream
    text/plain
rhrjs    r9�test_nested_with_same_boundaryz,TestMultipart.test_nested_with_same_boundary,sI��
�
"�
"���l�l�<�(���j�����S�#�&�
�3�<�<�>��	r;c�f�|jd�}|j|j�d�y)Nz
msg_40.txtz�MIME-Version: 1.0
Content-Type: text/html; boundary="--961284236552522269"

----961284236552522269
Content-Type: text/html;
Content-Transfer-Encoding: 7Bit

<html></html>

----961284236552522269--
)r3r2r�rhs  r9�test_boundary_in_non_multipartz,TestMultipart.test_boundary_in_non_multipart=s+���l�l�<�(���������+�	r;c���|j}tjd�}|j|j	��||j�d�|t
|j��d�y)Nz�MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="    XXXX"

--    XXXX
Content-Type: text/plain


--    XXXX
Content-Type: text/plain

--    XXXX--
z    XXXXr�)r2r�r�r�rr�r�rZr5s   r9� test_boundary_with_leading_spacez.TestMultipart.test_boundary_with_leading_spaceLsb��
�
�
���'�'�)���	
����(�(�*�+�
�3����z�*�
�3�s��� �!�1�%r;c��t�jd�}|j|jd�j�d�y)Nz�Content-Type: multipart/mixed; boundary="===============0012394164=="
MIME-Version: 1.0

--===============0012394164==
Content-Type: image/file1.jpg
MIME-Version: 1.0
Content-Transfer-Encoding: base64

YXNkZg==
--===============0012394164==--rzYXNkZg==)rr�r2rZr�s  r9�&test_boundary_without_trailing_newlinez4TestMultipart.test_boundary_without_trailing_newline_s=���H���
#�

$��	
������q�)�5�5�7��Dr;c��tdd�}|j|jtjj�y)Nr&r')rr�r�r��compat32r�s  r9�test_mimebase_default_policyz*TestMultipart.test_mimebase_default_policyms*���[�'�*���
�
�a�h�h���� 5� 5�6r;c��tddtjj��}|j	|jtjj�y)Nr&r'r�)rr�r��defaultr�r�s  r9�test_mimebase_custom_policyz)TestMultipart.test_mimebase_custom_policyqs6���[�'�%�,�,�2F�2F�G���
�
�a�h�h���� 4� 4�5r;N)r�r�r�r�r@rBrIrMrQrTrWr[r]r_rdrfrkrmrorqrsrvryr�r;r9r$r$�sh��"�H,�$5�"�$�*�2�8�6�6�6�6<�4��&�"
�&�&E�7�6r;r$c�~�eZdZd�Zd�Zd�Zejd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�Zd
�Zd�Zy)�TestNonConformantc���|j}|jd�}||j�d�||j�d�||j	�d�y)Nz
msg_14.txtr?r�r})r2r3rHrkrr5s   r9�test_parse_missing_minor_typez/TestNonConformant.test_parse_missing_minor_typexsT��
�
�
���l�l�<�(��
�3���!�<�0�
�3�#�#�%�v�.�
�3�"�"�$�g�.r;c�"�|jd�}|jd�}|jt|d��|j	t|j�d�|j|jdtj�y)N�
msg_15.txtrr�r|)
r3rZr��hasattrr2r�r�r�r �StartBoundaryNotFoundDefect)r6r8�inners   r9�test_same_boundary_inner_outerz0TestNonConformant.test_same_boundary_inner_outer�sm���l�l�<�(������"�������y�1�2�����U�]�]�+�Q�/����e�m�m�A�.�$�@�@�	Br;c�l�|jd�}|j|j�t�|j	t|j�d�|j|jdtj�|j|jdtj�y)Nz
msg_25.txtr�rr|)
r3r�rZr�r2r�r�r �NoBoundaryInMultipartDefect�!MultipartInvariantViolationDefectrhs  r9�test_multipart_no_boundaryz,TestNonConformant.test_multipart_no_boundary�s����l�l�<�(�����c�o�o�/��5�����S�[�[�)�1�-����c�k�k�!�n�$�@�@�	B����c�k�k�!�n�$�F�F�	Hr;a^        Date: Wed, 14 Nov 2007 12:56:23 GMT
        From: foo@bar.invalid
        To: foo@bar.invalid
        Subject: Content-Transfer-Encoding: base64 and multipart
        MIME-Version: 1.0
        Content-Type: multipart/mixed;
            boundary="===============3344438784458119861=="{}

        --===============3344438784458119861==
        Content-Type: text/plain

        Test message

        --===============3344438784458119861==
        Content-Type: application/octet-stream
        Content-Transfer-Encoding: base64

        YWJj

        --===============3344438784458119861==--
        c��|j|jjd��}|jt	|j
�d�|j
|j
dtj�y)Nz"
Content-Transfer-Encoding: base64r|r)	�_str_msg�
multipart_msgr�r2r�r�r�r �-InvalidMultipartContentTransferEncodingDefectrhs  r9�test_multipart_invalid_ctez,TestNonConformant.test_multipart_invalid_cte�sa���m�m����%�%�&K�L�N������S�[�[�)�1�-����c�k�k�!�n��@�@�	Br;c��|j|jjd��}|jt	|j
�d�y)Nr+r�r�r�r�r2r�r�rhs  r9�test_multipart_no_cte_no_defectz1TestNonConformant.test_multipart_no_cte_no_defect�s:���m�m�D�.�.�5�5�b�9�:������S�[�[�)�1�-r;c���dD]`}|j|jjdj|���}|jt	|j
�d��by)N)r�r`�BINaryz
Content-Transfer-Encoding: {}rr�)r6r�r8s   r9�"test_multipart_valid_cte_no_defectz4TestNonConformant.test_multipart_valid_cte_no_defect�s^��-�	2�C��-�-��"�"�)�)�5�<�<�S�A�C�D�C�
���S����-�q�1�		2r;c���|j}|j}t�}d|d<||j�d�||j	�d�||j�d�|d=d|d<||j�d�||j	�d�||j�d�t
�}t|�}|j|�||j�d�y)Nr�rDr}r?r@r�zContent-Type: foo

)
r2r	rrkrrHrrr�r�)r6r7�neqr8r�r�s      r9�test_invalid_content_typez+TestNonConformant.test_invalid_content_type�s���
�
�
���#�#���i��$��N��
�3�#�#�%�v�.�
�3�"�"�$�g�.�
�3���!�<�0����#��N��
�3�#�#�%�v�.�
�3�"�"�$�g�.�
�3���!�<�0��J���a�L��	�	�	�#���A�J�J�L�1�2r;c�l�|j}|jd�}||j�d�y)N�
msg_31.txtzm--BOUNDARY
Content-Type: text/plain

message 1

--BOUNDARY
Content-Type: text/plain

message 2

--BOUNDARY--
)r	r3rZr5s   r9�test_no_start_boundaryz(TestNonConformant.test_no_start_boundary�s1��
�
"�
"���l�l�<�(��
�3�?�?���	r;c�l�|j}|jd�}||j�d�y)Nz
msg_35.txtz�From: aperson@dom.ain
To: bperson@dom.ain
Subject: here's something interesting

counter to RFC 2822, there's no separating newline here
)r	r3r�r5s   r9�test_no_separating_blank_linez/TestNonConformant.test_no_separating_blank_line�s0��
�
"�
"���l�l�<�(��
�3�=�=�?��	r;c�Z�|jd�}|jt|d��|jt	|j
�d�|j
|j
dtj�|j
|j
dtj�y)Nz
msg_41.txtr�r�rr|)
r3r�r�r2r�r�r�r r�r�rhs  r9�test_lying_multipartz&TestNonConformant.test_lying_multipart�s����l�l�<�(�������Y�/�0�����S�[�[�)�1�-����c�k�k�!�n�$�@�@�	B����c�k�k�!�n�$�F�F�	Hr;c�
�|jd�}|jd�jd�}|jt|j�d�|j|jdtj�y)Nz
msg_42.txtr|r)r3rZr2r�r�r�r r�)r6rH�bads   r9�test_missing_start_boundaryz-TestNonConformant.test_missing_start_boundary�sh�����\�*������"�.�.�q�1������S�[�[�)�1�-����c�k�k�!�n�$�@�@�	Br;c�v�|j}d}tj|�}||j�dg�||j	�d�|t|j�d�|j|jtjg�||jdjd�y)Nz Line 1
Subject: test

bodyr��bodyr|rz Line 1
)r2r�r�r�rZr�r��assertDefectsEqualr �#FirstHeaderLineIsContinuationDefect�liner�s    r9�&test_first_line_is_continuation_headerz8TestNonConformant.test_first_line_is_continuation_header	s���
�
�
��,���'�'��*��
�3�8�8�:�	�{�#�
�3�?�?��f�%�
�3�s�{�{��Q��������"(�"L�"L�!M�	O�
�3�;�;�q�>����,r;c��|jd�}|j|j�dg�|j|j�d�|j	|j
tjg�y)Nz&Subject: test
not a header
To: abc

b
r�znot a header
To: abc

b
)r�r2r�rZr�r�r � MissingHeaderBodySeparatorDefectrhs  r9�"test_missing_header_body_separatorz4TestNonConformant.test_missing_header_body_separator	sd��
�m�m�I�J���������i�[�1�������*�,J�K�������!'�!H�!H� I�	Kr;N)r�r�r�r}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r;r9r{r{vs`��/�B�H�$�H�O�O�%�
�M�0B�.�
2�3�*�"	�H�
B� 	-�	Kr;r{c�l�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zy)�TestRFC2047c���|j}d}t|�}||gd��t|�}|t|�d�|j	|jd��d�y)NzVRe: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz
 foo bar =?mac-iceland?q?r=8Aksm=9Arg=8Cs?=))sRe: N�s
r�ksm�rg�szmac-iceland)s
 baz foo bar Nr�u+Re: räksmörgås baz foo bar räksmörgåsr�rziRe: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz foo bar =?mac-iceland?q?r=8Aksm?=
 =?mac-iceland?q?=9Arg=8Cs?=)r2rrr�r	r��r6r7r��dhr�s     r9�test_rfc2047_multilinez"TestRFC2047.test_rfc2047_multiline&	sj��
�
�
��
/��
�1�
��
�2�5�	6�
�R���
�3�v�;�D�	F����f�m�m�r�m�:�= �	!r;c��|j}d}t|�}||ddg�tt|��}||d�y)Nz0=?ISO-8859-1?Q?Andr=E9?= Pirard <pirard@dom.ain>)sAndr�r=)s Pirard <pirard@dom.ain>NuAndré Pirard <pirard@dom.ain>�r2rr�rr�s     r9�test_whitespace_keeper_unicodez*TestRFC2047.test_whitespace_keeper_unicode7	sJ��
�
�
��>��
�1�
��
�2�+�3�5�	6��[��_�%��
�6�5�6r;c��|j}d}t|�}||gd��tt|��}||d�y)NzWThe =?iso-8859-1?b?cXVpY2sgYnJvd24gZm94?= jumped over the =?iso-8859-1?b?bGF6eSBkb2c=?=))sThe N)squick brown foxr=)s jumped over the N)slazy dogr=z,The quick brown fox jumped over the lazy dogr�)r6r7r�r��hus     r9� test_whitespace_keeper_unicode_2z,TestRFC2047.test_whitespace_keeper_unicode_2@	sF��
�
�
��e��
�1�
��
�2�K�	L�
��R��
!��
�2�=�>r;c�F�d}t|�}|j|gd��y)Nz3Sm=?ISO-8859-1?B?9g==?=rg=?ISO-8859-1?B?5Q==?=sbord))sSmN���r=)srgN���r=)ssbordN�rr2�r6r�r�s   r9�test_rfc2047_missing_whitespacez+TestRFC2047.test_rfc2047_missing_whitespaceI	s&��A��
�1�
������0�	1r;c�F�d}t|�}|j|gd��y)Nz7Sm =?ISO-8859-1?B?9g==?= rg =?ISO-8859-1?B?5Q==?= sbord))sSm Nr�)s rg Nr�)s sbordNr�r�s   r9�test_rfc2047_with_whitespacez(TestRFC2047.test_rfc2047_with_whitespaceP	s&��E��
�1�
������1�	2r;c�j�d}gd�}|D](\}}t||z�}|j||dfg��*y)Nz=?iso-8859-1?B?%s?=))zdm==�v)zdm=r�)�dmr�)zdmk=�vi)�dmkr�r=r�)r6r�r\�q�ar�s      r9�test_rfc2047_B_bad_paddingz&TestRFC2047.test_rfc2047_B_bad_paddingW	sI��!�����	6�D�A�q��q�1�u�%�B����R�1�l�"3�!4�5�	6r;c�@�d}|jt|�dg�y)Nz=?iso-8859-1?Q?andr=e9=zz?=)sandr�=zzr=�r2r�r6r�s  r9�test_rfc2047_Q_invalid_digitsz)TestRFC2047.test_rfc2047_Q_invalid_digitsa	s"��)������q�)�7�8�	:r;c�B�d}|jt|�gd��y)Nz(=?ISO-8859-1?Q?a?=))��(N��ar=��)Nr�r�s  r9�test_rfc2047_rfc2047_1z"TestRFC2047.test_rfc2047_rfc2047_1g	s ��"������q�)�>�	@r;c�B�d}|jt|�gd��y)Nz(=?ISO-8859-1?Q?a?= b))r�r�)s b)Nr�r�s  r9�test_rfc2047_rfc2047_2z"TestRFC2047.test_rfc2047_rfc2047_2m	� ��$������q�)�@�	Br;c�B�d}|jt|�gd��y)Nz'(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)�r�)sabr=r�r�r�s  r9�test_rfc2047_rfc2047_3z"TestRFC2047.test_rfc2047_rfc2047_3s	s ��5������q�)�?�	Ar;c�B�d}|jt|�gd��y)Nz((=?ISO-8859-1?Q?a?=  =?ISO-8859-1?Q?b?=)r�r�r�s  r9�test_rfc2047_rfc2047_4z"TestRFC2047.test_rfc2047_rfc2047_4y	s ��6������q�)�?�	Ar;c�B�d}|jt|�gd��y)Nz,(=?ISO-8859-1?Q?a?=
    =?ISO-8859-1?Q?b?=)r�r�r�s  r9�test_rfc2047_rfc2047_5az#TestRFC2047.test_rfc2047_rfc2047_5a	s ��<������q�)�?�	Ar;c�B�d}|jt|�gd��y)Nz+(=?ISO-8859-1?Q?a?=
    =?ISO-8859-1?Q?b?=)r�r�r�s  r9�test_rfc2047_rfc2047_5bz#TestRFC2047.test_rfc2047_rfc2047_5b�	s ��:������q�)�?�	Ar;c�B�d}|jt|�gd��y)Nz(=?ISO-8859-1?Q?a_b?=))r�)sa br=r�r�r�s  r9�test_rfc2047_rfc2047_6z"TestRFC2047.test_rfc2047_rfc2047_6�	r�r;c	��d}|jt|�gd��|jtt|��j�|j	��|jttt|���d�y)Nz((=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=))r�r�)s brrr�z(a b))r2rrr�r�r�r�s  r9�test_rfc2047_rfc2047_7z"TestRFC2047.test_rfc2047_rfc2047_7�	sk��6������q�)�
�	�	
����]�1�%5�6�=�=�?�����K�����[��q�)9�:�;�W�Er;c	�:�d}|jt|�ddg�|jtt|��j�dj	|j���|jt
tt|���d�y)Nz9=?windows-1252?q?=22M=FCller_T=22?=
 <T.Mueller@xxx.com>)s
"M�ller T"zwindows-1252)s<T.Mueller@xxx.com>Nr+u"Müller T" <T.Mueller@xxx.com>)r2rrr�r��
splitlinesr�r�s  r9�test_multiline_headerz!TestRFC2047.test_multiline_header�	s���I������q�)�
/�
+�
-�	.�	
����]�1�%5�6�=�=�?��������0�	2�����[��q�)9�:�;�:�	<r;N)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r;r9r�r�%	sZ��!�"7�?�1�2�6�:�@�B�A�A�A�A�B�F�<r;r�c�l�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zy)�TestMIMEMessagec�r�tdd��5}|j�|_ddd�y#1swYyxYw)N�
msg_11.txtrVr�)r'r��_text�r6r�s  r9r�zTestMIMEMessage.setUp�	s0��
�l�W�
5�	#������D�J�	#�	#�	#�s�-�6c�:�|jttd�y)Nza plain string)r�rmrr�s r9�test_type_errorzTestMIMEMessage.test_type_error�	s�����)�[�2B�Cr;c�8�|j}d}t�}||d<t|�}||j�d�|j	�}|j|t�|t|�d�|d}|j||�||d|�y)Nz
A sub-messager�rXr|r�subject)	r2rrrHrZr��listr�r�)r6r7r�r��rr�r�s       r9�test_valid_argumentz#TestMIMEMessage.test_valid_argument�	s���
�
�
��!���I����)����N��
�1����!1�2��-�-�/�����g�t�,�
�3�w�<����!�*���
�
�g�q�!�
�7�9��w�'r;c��t�}d|d<t�}d|d<t|�}|jtj|j
|�y)N�	subpart 1r�z	subpart 2)rrr�r �MultipartConversionErrorrn)r6rbr�r�s    r9�test_bad_multipartz"TestMIMEMessage.test_bad_multipart�	sH���y��%��Y���y��%��Y���������&�9�9�1�8�8�T�Jr;c���t�}d|d<|jd�t|�}d|d<t�}t	|�}|j|�|j
|j�d�y)N�An enclosed messager��!Here is the body of the message.
zThe enclosing messagez�Content-Type: message/rfc822
MIME-Version: 1.0
Subject: The enclosing message

Subject: An enclosed message

Here is the body of the message.
)rrRrrrr�r2r�)r6r�r�r�r�s     r9�
test_generatezTestMIMEMessage.test_generate�	sg���I��,��)��	�
�
�:�;���N��.��)���J���a�L��	�	�	�!���������(�	r;c�X�|j}|jd�}||j�d�|j�}|j	|t
�|t
|�d�|d}|j	|t�||dd�||j�d�y)Nr�rXr|rr�r�r�)r2r3rHrZr�r�r�r)r6r7r8r��submsgs     r9�test_parse_message_rfc822z)TestMIMEMessage.test_parse_message_rfc822�	s���
�
�
���l�l�<�(��
�3���!�#3�4��/�/�#�����g�t�,�
�3�w�<����������f�g�.�
�6�)��3�4�
�6����!E�Fr;c���|j}|jd�}||j�d�|j|j	��|t|j
��d�|j
d�}||j�d�||j
�d�|j
d�}||j�d�|t|j
��d	�|j
d�}|j|t�||d
d�||jdd
��d�||jdd
��d�|j
d�}|j|t�||dd�||jd��ddg�||jdd��d�|j
d	�}||j�d�|j
�}|j|t�|t|�d�|d}|j|t�||j�d�||dd�y)N�
msg_16.txtr5r�rr?a�This report relates to a message you sent with the following header fields:

  Message-id: <002001c144a6$8752e060$56104586@oxy.edu>
  Date: Sun, 23 Sep 2001 20:10:55 -0700
  From: "Ian T. Henry" <henryi@oxy.edu>
  To: SoCal Raves <scr@socal-raves.org>
  Subject: [scr] yeah for Ians!!

Your message cannot be delivered to the following recipients:

  Recipient address: jangel1@cougar.noc.ucla.edu
  Reason: recipient reached disk quota

r|zmessage/delivery-statusr�zoriginal-envelope-idz"0GK500B4HD0888@cougar.noc.ucla.edu�dnsz
reporting-mtarr+�nsd�action�failedzoriginal-recipient)r�r+)zjangel1@cougar.noc.ucla.edur+r�zfinal-recipientrX�
message-idz(<002001c144a6$8752e060$56104586@oxy.edu>)r2r3rHr�rr�rZr�rrIrr�)r6r7r8r��dsn1�dsn2r�rcs        r9�test_dsnzTestMIMEMessage.test_dsn�	s"��
�
�
���l�l�<�(��
�3���!�#5�6�����(�(�*�+�
�3�s��� �!�1�%��/�/�!�$��
�7�#�#�%�|�4�
�7��� �#�	�$�/�/�!�$��
�7�#�#�%�'@�A�
�3�w�"�"�$�%�q�)��"�"�1�%�����d�G�,�
�4�&�'�)M�N�
�4�>�>�%��>�8�"�=�
�4�>�>�%��>�8�$�?��"�"�1�%�����d�G�,�
�4��>�8�$�
�4�?�?�"6�?�7��?�@�	B�
�4�>�>�(�+<�>�=�r�B��/�/�!�$��
�7�#�#�%�'7�8��%�%�'�����g�t�,�
�3�w�<����Q�Z�
����j�'�2�
�:�&�&�(�,�7�
�:�l�#�5�	7r;c���|j}tdd��5}|j�}ddd�t�}d|d<d|d<d|d	<d
|_d|_t
d�}t
d
�}|jddd��|j|�|j|�t�}t|�}|j|�||j��y#1swY��xYw)N�
msg_21.txtrVr�rEr�rFr�rCr��MIME messagezEnd of MIME message
r�r�rDrkr�r()
r	r'r�rrKrLrrErnrrr�r�)	r6r7r�r�r8rbr�rr�s	         r9�
test_epiloguezTestMIMEMessage.test_epilogue
s���
�
"�
"��
�l�W�
5�	���7�7�9�D�	��i��'��F��%��D�	���I��%���.��������������~�'8�:��N��
�
�4���
�
�4���j���c�N��	�	�	�#��
�3�<�<�>�4� �!	�	�s�C$�$C-c�0�|j}t�}d|d<d|d<d|d<d|_d|_t	d	�}t	d
�}|jddd
��|j
|�|j
|�||j�d�y)NrEr�rFr�rCr�rr+r�r�rDrkr�r(adFrom: aperson@dom.ain
To: bperson@dom.ain
Subject: Test
Content-Type: multipart/mixed; boundary="BOUNDARY"

MIME message
--BOUNDARY
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

One
--BOUNDARY
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

Two
--BOUNDARY--
)r	rrKrLrrErnr�)r6r7r8rbr�s     r9�test_no_nl_preamblez#TestMIMEMessage.test_no_nl_preamble1
s���
�
"�
"���i��'��F��%��D�	���I��%�����������������~�'8�:��N��
�
�4���
�
�4��
�3�=�=�?��	r;c��|j}tdd��5}tj|�}ddd�j	d�}||j�d�||j
�d�|j	d�}||j�d�||j
�d�|j	d�}||j�d�||j
�d�|j	d�}||j�d�||j
�d�y#1swY��xYw)Nr\rVr�rrXr|r?�r2r'r��message_from_filerZ�get_default_typerH�r6r7r�r8�
container1�
container2�container1a�container2as        r9�test_default_typez!TestMIMEMessage.test_default_typeT
���
�
�
��
�l�W�
5�	.���)�)�"�-�C�	.��_�_�Q�'�
�
�:�&�&�(�*:�;�
�:�&�&�(�*:�;��_�_�Q�'�
�
�:�&�&�(�*:�;�
�:�&�&�(�*:�;� �,�,�Q�/��
�;�'�'�)�<�8�
�;�'�'�)�<�8� �,�,�Q�/��
�;�'�'�)�<�8�
�;�'�'�)�<�8�	.�	.���D5�5D?c��|j}tdd��5}tj|�}ddd�j	d�}||j�d�||j
�d�|j	d�}||j�d�||j
�d�|j	d�}||j�d�||j
�d�|j	d�}||j�d�||j
�d�y#1swY��xYw)NrarVr�rrXr|r?rrs        r9�.test_default_type_with_explicit_container_typez>TestMIMEMessage.test_default_type_with_explicit_container_typee
rrc���|j}|j}tdd�}d|_t	d�}t	d�}t|�}t|�}|j
|�|j
|�||j�d�||j�d�||j�d�||j�d�||jd�d�|d	=|d
=|d	=|d
=||j�d�||j�d�||j�d�||j�d�||jd�d�y)N�digestr�r+�
message 1
�
message 2
rXra�Content-Type: multipart/digest; boundary="BOUNDARY"
MIME-Version: 1.0

--BOUNDARY
Content-Type: message/rfc822
MIME-Version: 1.0

Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

message 1

--BOUNDARY
Content-Type: message/rfc822
MIME-Version: 1.0

Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

message 2

--BOUNDARY--
r@r>aBContent-Type: multipart/digest; boundary="BOUNDARY"
MIME-Version: 1.0

--BOUNDARY

Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

message 1

--BOUNDARY

Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

message 2

--BOUNDARY--
)
r2r	rrLrrrnrHrr�)r6r7r�r4�	subpart1a�	subpart2a�subpart1�subpart2s        r9�test_default_type_non_parsedz,TestMIMEMessage.test_default_type_non_parsedv
sf��
�
�
���#�#��!�(�J�7�	��	���]�+�	��]�+�	��y�)���y�)������"�����"�
�8�$�$�&�(8�9�
�8�$�$�&�(8�9�
�8�$�$�&�(8�9�
�8�$�$�&�(8�9��I����"�%�	�4
�^�$��^�$��^�$��^�$�
�8�$�$�&�(8�9�
�8�$�$�&�(8�9�
�8�$�$�&�(8�9�
�8�$�$�&�(8�9��I����"�%�	r;c��|j}td�}td�}t||f��}|t|j	��d�||j	d�|�||j	d�|�y)Nr+)�	_subpartsr�rr|)r2rrr�rZ)r6r7�text1�text2r8s     r9�$test_mime_attachments_in_constructorz4TestMIMEMessage.test_mime_attachments_in_constructor�
si��
�
�
�����������u�e�n�5��
�3�s��� �!�1�%�
�3�?�?�1��u�%�
�3�?�?�1��u�%r;c�V�t�}|j|j��yrf)rr�rrhs  r9�"test_default_multipart_constructorz2TestMIMEMessage.test_default_multipart_constructor�
s���o������(�(�*�+r;c�r�t�}d|d<d|d<|j|jd�ddg�y)N�a@b.comr��c@d.comr�)rr2r4rhs  r9�test_multipart_default_policyz-TestMIMEMessage.test_multipart_default_policy�
s9���o����D�	���D�	�������T�*�Y�	�,B�Cr;c��ttjj��}d|d<|j	t
�5}d|d<ddd�|j
tj�d�y#1swY�/xYw)Nr�r.r�r/z.There may be at most 1 To headers in a message)	rr�r�rxr�rOr2r��	exception)r6r8�cms   r9�test_multipart_custom_policyz,TestMIMEMessage.test_multipart_custom_policy�
sj���5�<�<�#7�#7�8����D�	�
�
�
�z�
*�	"�b�!�C��I�	"�����R�\�\�*�I�	K�	"�	"�s�A3�3A<N)r�r�r�r�r�r�r�r�r�rrrrrr%r*r,r0r4r�r;r9r�r��	s[��#�D�(�K��(
G�77�r!�(!�F9�"9�"H�T&�,�D�Kr;r�c��eZdZd�Zd�Zy)�TestNonMultipartc�Z�tdd�}|j|j��y)Nr�r})rrrrhs  r9�"test_nonmultipart_is_not_multipartz3TestNonMultipart.test_nonmultipart_is_not_multipart�
s%���v�w�/������)�)�+�,r;c��t�}d|d<tdd�}|jtj|j
|�y)Nr�r�r�r})rrr�r r�rn)r6r8r�s   r9�test_attach_raises_exceptionz-TestNonMultipart.test_attach_raises_exception�
s:���i��$��I���V�W�-�����&�9�9�1�8�8�S�Ir;N)r�r�r�r8r:r�r;r9r6r6�
s
��-�Jr;r6c��eZdZdZd�Zdd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�TestIdempotentr*c��t|d��5}|j�}ddd�tj�}||fS#1swY�"xYw�NrVr��r'r�r�r��r6rBr�r\r8s     r9r3zTestIdempotent._msgobj�
sH��
�h��
1�	�R��7�7�9�D�	��'�'��-���D�y��	�	�s�A�A	c��|j}t�}t|d��}|j||��|||j	��y)Nrrqr�)r	rrr�r�)r6r8r�r�r7r�r�s       r9�_idempotentzTestIdempotent._idempotent�
s@��
�
"�
"���J���a�a�(��	�	�	�#��	�)�
�4�����r;c��|j}|jd�\}}||j�d�||j�d�||j	�d�||j�dd�||j
d�d�||jd�||jd�|j||�y)	Nr�r?r�r}r|)rArNrArN)
r2r3rHrkrrrIrKrLrB�r6r7r8r�s    r9�test_parse_text_messagez&TestIdempotent.test_parse_text_message�
s���
�
�
���L�L��.�	��T�
�3���!�<�0�
�3�#�#�%�v�.�
�3�"�"�$�g�.�
�3�>�>��A�� 7�8�
�3�=�=��#�Z�0�
�3�<�<���
�3�<�<�������d�#r;c���|j}|jd�\}}||j�d�||j�d�||j	d�d�|j||�y)Nr�r?rA)r2r3rHrrIrBrDs    r9�test_parse_untyped_messagez)TestIdempotent.test_parse_untyped_messagesf��
�
�
���L�L��.�	��T�
�3���!�<�0�
�3�>�>��T�"�
�3�=�=��#�T�*�����d�#r;c�P�|jd�\}}|j||�y)Nry�r3rB�r6r8r�s   r9�test_simple_multipartz$TestIdempotent.test_simple_multipart�$���L�L��.�	��T�����d�#r;c�P�|jd�\}}|j||�y)N�
msg_02.txtrIrJs   r9�test_MIME_digestzTestIdempotent.test_MIME_digestrLr;c�P�|jd�\}}|j||�y)Nz
msg_27.txtrIrJs   r9�test_long_headerzTestIdempotent.test_long_headerrLr;c�P�|jd�\}}|j||�y)NrarIrJs   r9�"test_MIME_digest_with_part_headersz1TestIdempotent.test_MIME_digest_with_part_headersrLr;c�P�|jd�\}}|j||�y)N�
msg_06.txtrIrJs   r9�test_mixed_with_imagez$TestIdempotent.test_mixed_with_image#rLr;c�P�|jd�\}}|j||�y)Nr3rIrJs   r9�test_multipart_reportz$TestIdempotent.test_multipart_report'rLr;c�P�|jd�\}}|j||�y)NrrIrJs   r9rzTestIdempotent.test_dsn+rLr;c�P�|jd�\}}|j||�y)Nr
rIrJs   r9�test_preamble_epiloguez%TestIdempotent.test_preamble_epilogue/rLr;c�P�|jd�\}}|j||�y)Nz
msg_23.txtrIrJs   r9�test_multipart_one_partz&TestIdempotent.test_multipart_one_part3rLr;c�P�|jd�\}}|j||�y)Nz
msg_24.txtrIrJs   r9�test_multipart_no_partsz&TestIdempotent.test_multipart_no_parts7rLr;c�P�|jd�\}}|j||�y)Nr�rIrJs   r9r�z%TestIdempotent.test_no_start_boundary;rLr;c�P�|jd�\}}|j||�y)N�
msg_32.txtrIrJs   r9�test_rfc2231_charsetz#TestIdempotent.test_rfc2231_charset?rLr;c�P�|jd�\}}|j||�y)Nz
msg_33.txtrIrJs   r9�test_more_rfc2231_parametersz+TestIdempotent.test_more_rfc2231_parametersCrLr;c�P�|jd�\}}|j||�y)Nz
msg_34.txtrIrJs   r9�%test_text_plain_in_a_multipart_digestz4TestIdempotent.test_text_plain_in_a_multipart_digestGrLr;c�P�|jd�\}}|j||�y)Nzmsg_12a.txtrIrJs   r9�test_nested_multipart_mixedsz+TestIdempotent.test_nested_multipart_mixedsKs$���L�L��/�	��T�����d�#r;c�P�|jd�\}}|j||�y)NrarIrJs   r9�%test_message_external_body_idempotentz4TestIdempotent.test_message_external_body_idempotentOrLr;c�T�|jd�\}}|j||d��y)N�
msg_43.txtTr�rIrJs   r9�test_message_delivery_statusz+TestIdempotent.test_message_delivery_statusSs)���L�L��.�	��T�����d�T��2r;c�P�|jd�\}}|j||�y�N�
msg_45.txtrIrJs   r9�test_message_signed_idempotentz-TestIdempotent.test_message_signed_idempotentWrLr;c�4�|j}|jd�\}}||j�d�i}|j�D]
\}}|||<�||dd�||dd�||jd|j
z�||j|j
�|t|j��d�|jd	�}||j�d
�||j�d|j
z�|jd�}||j�d
�||j�d|j
z�|jd
�}	||	j�d�|j|	t�|	j�}
|j|
t�|t|
�d�|
d	}|j|t�||j�d|j
z�y)Nr3r5r6r7rr9z$This is a MIME-encapsulated message.r�rr?zYadda yadda yaddar|r�rX)r2r3rHrrKr�rLr�rZr�rr�)r6r7r8r��params�pk�pvrbr��msg3r��msg4s            r9�test_content_typez TestIdempotent.test_content_type[s���
�
�
���L�L��.�	��T�
�3���!�#5�6����n�n�&�	�F�B���F�2�J�	�
�6�-� �"3�4�
�6�*��F�G�
�3�<�<�?�$�,�,�N�O�
�3�<�<����&�
�3�s��� �!�1�%����q�!��
�4� � �"�L�1�
�4����2�T�\�\�A�B����q�!��
�4� � �"�L�1�
�4����2�T�\�\�A�B����q�!��
�4� � �"�$4�5����d�G�,��"�"�$�����g�t�,�
�3�w�<����q�z�����d�G�,�
�4����2�T�\�\�A�Br;c���|j}|jd�\}}||j�d�|j�}|j	|t
�|t
|�d�|d}|j	|t�||j�d�|j	|j�t�||j�|j�y)NrUrXr|rr?)
r2r3rHrZr�r�r�rr�r�)r6r7r8r�r�rbs      r9�test_parserzTestIdempotent.test_parserzs���
�
�
���L�L��.�	��T�
�3���!�#3�4��/�/�#�����g�t�,�
�3�w�<����q�z�����d�G�,�
�4� � �"�L�1����d�.�.�0�#�6�
�4����t�|�|�,r;N�F)r�r�r�r�r3rBrErGrKrOrQrSrVrXrr[r]r_r�rcrergrirkrnrrryr{r�r;r9r<r<�
s����G���
$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�3�$�C�>-r;r<c��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&d%�Z'd&�Z(d'�Z)d(�Z*d)�Z+d*�Z,e-j\�e/j`d+�d,���Z1d-�Z2d.�Z3d/�Z4d0�Z5d1�Z6d2�Z7d3�Z8d4�Z9d5�Z:d6�Z;d7�Z<d8�Z=y9):�TestMiscellaneousc�"�tdd��5}|j�}ddd�tj�}t	�}t|d��}|j
|�|j||j��y#1swY�gxYw�Nr�rVr�rrq�	r'r�r�r�rrr�r2r��r6r�r�r8r�r�s      r9�test_message_from_stringz*TestMiscellaneous.test_message_from_string�st��
�l�W�
5�	���7�7�9�D�	��'�'��-���J��
�a�a�(��	�	�	�#������q�z�z�|�,�	�	�s�B�Bc�D�tdd��5}|j�}|jd�tj|�}t�}t
|d��}|j|�|j||j��ddd�y#1swYyxYwr�)
r'r��seekr�rrrr�r2r�r�s      r9�test_message_from_filez(TestMiscellaneous.test_message_from_file�s��
�l�W�
5�		1���7�7�9�D��G�G�A�J��)�)�"�-�C��
�A��!�!�,�A�
�I�I�c�N����T�1�:�:�<�0�		1�		1�		1�s�A?B�Bc��tdd��5}|j�}ddd�Gd�dt�}tj|�}|j||�tdd��5}|j�}ddd�tj||�}|j
�D]}|j||��y#1swY��xYw#1swY�SxYw)Nr�rVr�c��eZdZy)�HTestMiscellaneous.test_message_from_string_with_class.<locals>.MyMessageN�r�r�r�r�r;r9�	MyMessager�����r;r�rN)r'r�rr�r�r��walk)r6r�r�r�r8r�s      r9�#test_message_from_string_with_classz5TestMiscellaneous.test_message_from_string_with_class�s���
�l�W�
5�	���7�7�9�D�	�	��	��'�'��i�8�����c�9�-�
�l�W�
5�	���7�7�9�D�	��'�'��i�8���x�x�z�	6�G��!�!�'�9�5�	6�	�	��	�	�s�C�+C�C�Cc�t�Gd�dt�}tdd��5}tj||�}ddd�|j	|�tdd��5}tj||�}ddd�|j�D]}|j	||��y#1swY�oxYw#1swY�=xYw)Nc��eZdZy)�FTestMiscellaneous.test_message_from_file_with_class.<locals>.MyMessageNr�r�r;r9r�r��r�r;r�r�rVr�rN)rr'r�rr�r�)r6r�r�r8r�s     r9�!test_message_from_file_with_classz3TestMiscellaneous.test_message_from_file_with_class�s���	��	��l�W�
5�	9���)�)�"�i�8�C�	9����c�9�-�
�l�W�
5�	9���)�)�"�i�8�C�	9��x�x�z�	6�G��!�!�'�9�5�	6�
	9�	9��	9�	9�s�B"�B.�"B+�.B7c�j�Gd�dt�}|jd|�}|j||�y)Nc���eZdZ�fd�Z�xZS)�STestMiscellaneous.test_custom_message_does_not_require_arguments.<locals>.MyMessagec�"��t�|��yrf)�super�__init__)r6�	__class__s �r9r�z\TestMiscellaneous.test_custom_message_does_not_require_arguments.<locals>.MyMessage.__init__�s����� �"r;)r�r�r�r��
__classcell__)r�s@r9r�r��s
���
#�
#r;r�zSubject: test

test)rr�r�)r6r�r8s   r9�.test_custom_message_does_not_require_argumentsz@TestMiscellaneous.test_custom_message_does_not_require_arguments�s1��	#��	#��m�m�3�Y�?�����c�9�-r;c�h�td�}|jt|j�gd��y)Nr�)rrArr �
feedparserr�r�r!rn�message_from_binary_filer�rr�r�r�r"r#)�
__import__r2�sorted�__all__)r6�modules  r9�test__all__zTestMiscellaneous.test__all__�s*���G�$���������/�2�	r;c���tj�}|jtjtj|��ddtj
|�dd�y)N�)r.r2r#�	parsedate�
formatdate�gmtime�r6r6s  r9�test_formatdatez!TestMiscellaneous.test_formatdate�sK���i�i�k���������)9�)9�#�)>�?���C����S�)�"�1�-�	/r;c���tj�}|jtjtj|d���ddtj
|�dd�y)NT�r/r�)r.r2r#r�r�r/r�s  r9�test_formatdate_localtimez+TestMiscellaneous.test_formatdate_localtime�sN���i�i�k������O�O�E�,�,�S�D�A�B�2�A�F��N�N�3����#�	%r;c	�f�tj�}|jtj|d��tjdtj
|���|jtj|dd��tjdtj
|���y)NFr�z%a, %d %b %Y %H:%M:%S -0000T)r/�usegmtz%a, %d %b %Y %H:%M:%S GMT)r.r2r#r�r2r�r�s  r9�test_formatdate_usegmtz(TestMiscellaneous.test_formatdate_usegmt�s���i�i�k��������S�E�2��M�M�7����S�9I�J�	L�	
������S�E�$�?��M�M�5�t�{�{�3�7G�H�	Jr;c��gd�}|D]e}|j|��5|jtj|��|jtj|��ddd��g|jtjd��|jtjd��y#1swY��xYw)N)	r+r,�0zA Complete Waste of Timez Wed, 3 Apr 2002 12.34.56.78+0800z17 June , 2022zFriday, -Nov-82 16:14:55 ESTzFriday, Nov--82 16:14:55 ESTzFriday, 19-Nov- 16:14:55 EST)�dtstr)�subTestr�r#r��parsedate_tz)r6�
invalid_datesr�s   r9�/test_parsedate_returns_None_for_invalid_stringszATestMiscellaneous.test_parsedate_returns_None_for_invalid_strings�s���

�
�#�	=�E����E��*�
=��!�!�%�/�/�%�"8�9��!�!�%�"4�"4�U�";�<�
=�
=�	=�
	
���%�/�/�$�/�0����%�,�,�T�2�3�
=�
=�s�A	B8�8C	c���|jtjd�d�|jtjd�d�|jtjd�d�y)NzWed, 3 Apr 2002 14:58:26 +0800�
��r�r���:�rr|r)�pzWed,3 Apr 2002 14:58:26 +0800zWed 3 Apr 2002 14:58:26 +0800�r2r#r�r�s r9�test_parsedate_compactz(TestMiscellaneous.test_parsedate_compactsf������+�+�,L�M�B�	D�	
����+�+�,K�L�B�	D�	
����+�+�,K�L�B�	Dr;c��|j}|tjd�d�|tjd�d�y)N�5 Feb 2003 13:47:26 -0800�
��r���
�/r�rr|r)透��zFebruary 5, 2003 13:47:26 -0800r��r6r7s  r9�test_parsedate_no_dayofweekz-TestMiscellaneous.test_parsedate_no_dayofweek
s?��
�
�
��
�5���9�:�5�	7�
�5���?�@�5�	7r;c�N�|jtjd�d�y)NzWed, 3 Apr 2002 14:58:26+0800r�r�r�s r9�.test_parsedate_no_space_before_positive_offsetz@TestMiscellaneous.test_parsedate_no_space_before_positive_offsets!������+�+�,K�L�4�	6r;c�N�|jtjd�d�y)NzWed, 3 Apr 2002 14:58:26-0800)
r�r�r�r�r�r�rr|r)r�r�r�s r9�.test_parsedate_no_space_before_negative_offsetz@TestMiscellaneous.test_parsedate_no_space_before_negative_offsets!������+�+�,K�L�5�	7r;c��|j}|tjd�d�|tjd�d�y)Nz5 Feb 2003 13.47.26 -0800r�z5 Feb 2003 13.47 -0800)
r�r�r�r�r�rrr|r)r�r�r�s  r9�%test_parsedate_accepts_time_with_dotsz7TestMiscellaneous.test_parsedate_accepts_time_with_dotss?��
�
�
��
�5���9�:�5�	7�
�5���6�7�4�	6r;c�N�|jtjd�d�y)NzFriday, 19-Nov-82 16:14:55 EST)
i����r��7rr|r)i����r�r�s r9�test_parsedate_rfc_850z(TestMiscellaneous.test_parsedate_rfc_850!s!������+�+�,L�M�7�	9r;c�N�|jtjd�d�y)NzWed, 3 Apr 2002 14:58 +0800�
r�r�r�r�r�rrr|r)r�r�r�s r9�test_parsedate_no_secondsz+TestMiscellaneous.test_parsedate_no_seconds%s"������+�+�,I�J�A�	Cr;c��|jtjd�d�|jtjd�d�y)NzWed, 3 Apr 2002 14.58.26 +0800r�zWed, 3 Apr 2002 14.58 +0800r�r�r�s r9�!test_parsedate_dot_time_delimiterz3TestMiscellaneous.test_parsedate_dot_time_delimiter)sB������+�+�,L�M�B�	D�����+�+�,I�J�A�	Cr;c
��|j}tjd�}tt	j
|��}|t	j|�dd|dd�|tt	jd|��d�tjd�}tt	j
|dd��}|t	j|�dd|dd�|tt	jd|dd��d�y)Nr�r�z%Yr��	)	r2r#r��intr.�mktimer/r2r�)r6r7�timetupr�s    r9�+test_parsedate_acceptable_to_time_functionsz=TestMiscellaneous.test_parsedate_acceptable_to_time_functions/s���
�
�
���/�/�"=�>������G�$�%��
�4�>�>�!��R�a� �'�"�1�+�.�
�3�t�}�}�T�7�+�,�d�3��$�$�%@�A������G�B�Q�K�(�)��
�4�>�>�!��R�a� �'�"�1�+�.�
�3�t�}�}�T�7�2�A�;�/�0�$�7r;c��|jtjd�d�|jtjd�d�y)N)
�r|r|rrrr)r)r)rr)
r�r|r|rrrr)r)r)i�i.���)r2r#�	mktime_tzr�s r9�test_mktime_tzz TestMiscellaneous.test_mktime_tz:sE��������*9�:�;<�	>�������*<�=�>C�	Er;c���|jtjd�tjd��|jtjd�tjd��y)aTest for parsing a date with a two-digit year.

        Parsing a date with a two-digit year should return the correct
        four-digit year. RFC822 allows two-digit years, but RFC2822 (which
        obsoletes RFC822) requires four-digit years.

        z25 Feb 03 13:47:26 -0800z25 Feb 2003 13:47:26 -0800z25 Feb 71 13:47:26 -0800z25 Feb 1971 13:47:26 -0800Nr�r�s r9�test_parsedate_y2kz$TestMiscellaneous.test_parsedate_y2k@s\��	
����+�+�,F�G��+�+�,H�I�	K�����+�+�,F�G��+�+�,H�I�	Kr;c��|jtjd�d�|jtjtjd��d�y)Nz<>�r+r+r+�r2r#�	parseaddr�
formataddrr�s r9�test_parseaddr_emptyz&TestMiscellaneous.test_parseaddr_emptyMs?���������.��9�����)�)�%�/�/�$�*?�@�"�Er;c���|jtjd�d�|jtjd�d�|jtjd�d�y)Nza@b@cr�za@b.c@cza@172.17.0.1@c�r2r#r�r�s r9�test_parseaddr_multiple_domainsz1TestMiscellaneous.test_parseaddr_multiple_domainsQs^������O�O�G�$��	
�	
����O�O�I�&��	
�	
����O�O�,�-��	
r;c�N�|jtjd�d�y)N)zA Silly Person�person@dom.ainzA Silly Person <person@dom.ain>�r2r#r�r�s r9�test_noquote_dumpz#TestMiscellaneous.test_noquote_dump_s"��������A�B�-�	/r;c��|jtjd�d�|jtjd�d�d}d}|jtjtj||f��||f�y)N)zA (Very) Silly Personr�z("A (Very) Silly Person" <person@dom.ain>z*"A \(Very\) Silly Person" <person@dom.ain>zA \(Special\) Personr��r2r#r�r��r6r�r�s   r9�test_escape_dumpz"TestMiscellaneous.test_escape_dumpdsz��������H�I�7�	9�	
����O�O�I�J�7�	9�
$�����������)9�)9�1�a�&�)A�B�Q��F�Kr;c���|jtjd�d�d}d}|jtjtj||f��||f�y)N)�Arthur \Backslash\ Foobarr�z."Arthur \\Backslash\\ Foobar" <person@dom.ain>r�r�r�r�s   r9�test_escape_backslashesz)TestMiscellaneous.test_escape_backslashesosZ��������M�N�=�	?�
)�����������)9�)9�1�a�&�)A�B�Q��F�Kr;c��d}d}d}d}|jtj||f�|�|jtj||fd�|�y)N�Häns Würstr��-=?utf-8?b?SMOkbnMgV8O8cnN0?= <person@dom.ain>z0=?iso-8859-1?q?H=E4ns_W=FCrst?= <person@dom.ain>r=r�)r6r�addr�utf8_base64�
latin1_quopris     r9�test_quotes_unicode_namesz+TestMiscellaneous.test_quotes_unicode_nameswsY��%����E��J�
�����)�)�4��,�7��E�����)�)�4��,��E��	r;c���d}d}d}d�G�fd�d�}|�}��d|�d�}|jtj||f|�|�|jtj||ftd	��|�y)
Nr�r�r��FOOBARc���eZdZ�fd�Zy)�KTestMiscellaneous.test_accepts_any_charset_like_object.<locals>.CharsetMockc����Srfr�)r6�stringrKs  �r9�
header_encodezYTestMiscellaneous.test_accepts_any_charset_like_object.<locals>.CharsetMock.header_encode�s����
r;N)r�r�r�r	)rKs�r9�CharsetMockr�s���
r;r
z <�>rV)r2r#r�r
)r6rr�rr
�mock�
mock_expectedrKs       @r9�$test_accepts_any_charset_like_objectz6TestMiscellaneous.test_accepts_any_charset_like_object�s~���%����E����	�	��}��%+�T�2�
�����)�)�4��,��=�}�M�����)�)�4��,���8H�I��	r;c�p�d}d}t�}|jttj||f|�y)Nr�r�)�objectr��AttributeErrorr#r�)r6rr��bad_charsets    r9�-test_invalid_charset_like_object_raises_errorz?TestMiscellaneous.test_invalid_charset_like_object_raises_error�s4��%�����h�����.�%�*:�*:�T�4�L��	r;c��d}|jttjd|f�|jttjd|f�y)Nupersön@dom.in�Name)r��UnicodeErrorr#r�)r6r�s  r9�!test_unicode_address_raises_errorz3TestMiscellaneous.test_unicode_address_raises_error�s?��#�����,��(8�(8�4��,�G����,��(8�(8�6�4�.�Ir;c��d}d}d\}}|jtj|�||f�|jtj|�||f�|jtj||f�|�y)NzJohn X. Doe <jxd@example.com>z"John X. Doe" <jxd@example.com>)zJohn X. Doezjxd@example.comr�)r6r��yr�r�s     r9�test_name_with_dotz$TestMiscellaneous.test_name_with_dot�sn��+��-��1���1��������+�a��V�4��������+�a��V�4�����)�)�1�a�&�1�1�5r;c���|j}|tjd�d�|tjd�d�|tjd�d�y)N�""example" example"@example.com)r+r�!"\"example\" example"@example.com)r+r�#"\\"example\\" example"@example.com)r+rr�r�s  r9�2test_parseaddr_preserves_quoted_pairs_in_addresseszDTestMiscellaneous.test_parseaddr_preserves_quoted_pairs_in_addresses�sT���
�
��
�5�?�?�<�=�
1�	3�
�5�?�?�@�A�
5�	7�
�5�?�?�D�E�
9�	;r;c�v�|jdtjd��|jdtjd��|jdtjd��|jdtjd��|jdtjd	��y)
N)r+�merwok wok@xample.comr!)r+�merwok  wok@xample.comr"z merwok  wok  @xample.com)r+�merwok"wok"  wok@xample.comr#)r+zmerwok.wok.wok@xample.comzmerwok. wok .  wok@xample.comr�r�s r9�-test_parseaddr_preserves_spaces_in_local_partz?TestMiscellaneous.test_parseaddr_preserves_spaces_in_local_part�s���	
���6��O�O�3�4�	6����7��O�O�4�5�	7����7��O�O�7�8�	:����<��O�O�9�:�	<����:��O�O�;�<�	>r;c��d}d}|jtj|�|�|jtj|�|�y)N)z#'foo@example.com' (foo@example.com)�foo@example.comz7"'foo@example.com' (foo@example.com)" <foo@example.com>r�)r6r��addrstrs   r9�6test_formataddr_does_not_quote_parens_in_quoted_stringzHTestMiscellaneous.test_formataddr_does_not_quote_parens_in_quoted_string�sE��#��C���������1�4�8�����)�)�$�/��9r;c�R�d}|jtj|�d�y)NzFoo
	Bar <foo@example.com>)zFoo Barr&r�)r6r�s  r9�test_multiline_from_commentz-TestMiscellaneous.test_multiline_from_comment�s%��
��	
�������+�-K�Lr;c�N�|jtjd�d�y)N)zA Silly; Personr�z""A Silly; Person" <person@dom.ain>r�r�s r9�test_quote_dumpz!TestMiscellaneous.test_quote_dump�s"��������B�C�1�	3r;c�X�|j}|j}t�}t�}||d�||d�||d�|d|�|d|�|d|�||d�||d�||d�|d|�|d|�|d|�|||�|||�y)NrN�US-ASCIIzUs-AsCiI�usascii�USASCII�UsAsCiI)r2�assertNotEqualr
)r6r7�ne�cset1�cset2s     r9�test_charset_richcomparisonsz.TestMiscellaneous.test_charset_richcomparisons�s���
�
�
��
�
 �
 ���	���	��
�5�*��
�5�*��
�5�*��
�:�u��
�:�u��
�:�u��
�5�)��
�5�)��
�5�)��
�9�e��
�9�e��
�9�e��
�5�%��
�5�%�r;c�\�|j}|tjddg�ddg�y)N�aperson@dom.ain (Al Person)zBud Person <bperson@dom.ain>�z	Al PersonrE)z
Bud PersonrF�r2r#�getaddressesr�s  r9�test_getaddressesz#TestMiscellaneous.test_getaddresses�s9��
�
�
��
�5���<�=�?�@�,�-�/�	0r;c�V�|jtjgd��gd��y)zGH-106669 regression test.)z"Bud, Person" <bperson@dom.ain>r8z#"Mariusz Felisiak" <to@example.com>))zBud, PersonrFr9)zMariusz Felisiakzto@example.comNr:r�s r9�test_getaddresses_comma_in_namez1TestMiscellaneous.test_getaddresses_comma_in_name�s(���������
�
�
	
r;c���|j}|tjdg�dg�|tjdg�gd��|tjddg�ddg�y)Nzfoo: ;r�z	[]*-- =~$)r�r�)r+z*--z#"Jason R. Mastaler" <jason@dom.ain>)zJason R. Mastalerz
jason@dom.ainr:r�s  r9�test_getaddresses_nastyz)TestMiscellaneous.test_getaddresses_nasty
sl��
�
�
��
�5���x�j�)�H�:�6�
�5����=��,�	.�	�5����;�<�>��<�=�	?r;c�f�|j}tjdg�}||ddd�y)z(Test proper handling of a nested commentz%User ((nested comment)) <foo@bar.com>rr|�foo@bar.comNr:)r6r7�addrss   r9�"test_getaddresses_embedded_commentz4TestMiscellaneous.test_getaddresses_embedded_comment
s3��
�
�
���"�"�$K�#L�M��
�5��8�A�;�
�&r;c�r�tjtd�g�}|j|ddd�y)z%Test the handling of a Header object.zAl Person <aperson@dom.ain>rr|rEN)r#r;rr2)r6rCs  r9�test_getaddresses_header_objz.TestMiscellaneous.test_getaddresses_header_obj
s4���"�"�F�+H�$I�#J�K������q��!��&7�8r;�cpuc�h�Gd�dt�}td�D�cgc]	}|���}}tj|�5	ddd�t	|D�cgc]}|j
��c}g�}|j
tt|��t|��ycc}w#1swY�`xYwcc}w)Nc��eZdZd�Zy)�BTestMiscellaneous.test_make_msgid_collisions.<locals>.MsgidsThreadc���g|_|jj}tj}tj
}|�dz}|�|kr||d���|�|kr�yy)Ng@�testdomain-string��domain)�msgidsrr#�
make_msgidr.�	monotonic)r6rrP�clock�tfins     r9�runzFTestMiscellaneous.test_make_msgid_collisions.<locals>.MsgidsThread.run&
sY�� ������+�+��"�-�-�
������w��}���g��n��:�-@�A�B��g��nr;N)r�r�r�rTr�r;r9�MsgidsThreadrJ%
s��
Cr;rUr�)	rrEr%�
start_threads�sumrOr2r��set)r6rUr?�threadsr��all_idss      r9�test_make_msgid_collisionsz,TestMiscellaneous.test_make_msgid_collisions!
s���		C�6�		C�,1��8�4�a�<�>�4��4�
�
+�
+�G�
4�	��	���1�A�q�x�x�1�2�6������S��\�*�C��L�9��	5�	�	��1s�B�B#�B/�#B,c��|j}t�}|jddd��||j�d�y)NrCr?zfoo\wacky"namerA)r2rrErr5s   r9�test_utils_quote_unquotez*TestMiscellaneous.test_utils_quote_unquote6
sA��
�
�
���i�����,�l� 1�	�	3�
�3����0�1r;c�Z�td�}|j|j�d�y)Nz
not a charsetrW�r
r2�get_body_encoding�r6rAs  r9�)test_get_body_encoding_with_bogus_charsetz;TestMiscellaneous.test_get_body_encoding_with_bogus_charset=
s%���/�*������2�2�4�h�?r;c���|j}t�}d|d<||dd�|j�}|t|�d�||dd�t	|d�}||j�d�|j
d|�	�||j�d
�||jd��d�||d
d�t�}d|d<|j�}|t|�d�||dd�t	|d�}||j�tj�|j
d|�	�||j�d�||d
d�y)Nztext/plain; charset=UTF-8rDr@r|rrVrWr�rJ�aGVsbG8gd29ybGQ=
TrXrBztext/plain; charset="US-ASCII"rNr�r�)
r2rrur�r
r`rRrZrr�)r6r7r8rvrAs     r9�-test_get_body_encoding_with_uppercase_charsetz?TestMiscellaneous.test_get_body_encoding_with_uppercase_charsetA
sS��
�
�
���i��9��N��
�3�~�� ;�<��#�#�%��
�3�x�=�!��
�8�A�;�� ��(�1�+�&��
�7�$�$�&��1�������8�
�3�?�?��2�3�
�3�?�?�$�?�'��8�
�3�*�+�X�6��i��>��N���#�#�%��
�3�x�=�!��
�8�A�;�
�#��(�1�+�&��
�7�$�$�&��(?�(?�@����
�w��7�
�3�?�?��m�,�
�3�*�+�V�4r;c��td�}td�}|j|j�|j��y)NrNr.r_)r6�lc�ucs   r9�test_charsets_case_insensitivez0TestMiscellaneous.test_charsets_case_insensitive[
s8��
�Z�
 ��
�Z�
 ������-�-�/��1E�1E�1G�Hr;c��|j}|jd�}t�}tj||�||j�d�y)NrmaBmultipart/report
    text/plain
    message/delivery-status
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
    text/rfc822-headers
rhrjs    r9�1test_partial_falls_inside_message_delivery_statuszCTestMiscellaneous.test_partial_falls_inside_message_delivery_status`
sI��
�
"�
"��
�l�l�<�(���j�����S�#�&�
�3�<�<�>��	r;c�j�|jtjjd��ddd�y)NrLrMi��z@testdomain-string>�r2r�r#rPr�s r9�test_make_msgid_domainz(TestMiscellaneous.test_make_msgid_domain�
s0������K�K�"�"�*=�"�>�s�t�D�!�	#r;c�l�|jtjjdd��ddd�y)Nz
test-idstringrL)�idstringrNi���z!.test-idstring@testdomain-string>rmr�s r9�test_make_msgid_idstringz*TestMiscellaneous.test_make_msgid_idstring�
s9������K�K�"�"�O�*�
#�
,�,/�D�
2�/�	1r;c���td�5}dx|_}|jtjj�j
d|zdz��ddd�y#1swYyxYw)Nzsocket.getfqdnzpythontest.example.com�@r)r	�return_valuer�r�r#rP�endswith)r6�mock_getfqdnrNs   r9�test_make_msgid_default_domainz0TestMiscellaneous.test_make_msgid_default_domain�
sb��
�#�
$�	)��1I�I�L�%���O�O����&�&�(�1�1��&�L�3�&�(�
)�	)�	)�	)�s�AA!�!A*c�l�tddd��5}|j�}ddd�jdd�}tj|�}t�}tjj|�}|j|�|j|j�|�y#1swY��xYw)N�
msg_26.txtrVr*�r��newliner�)r'r�r�r�r�rr�rr�r2r��r6�f�msgtxt�	msgtxt_nlr8r�r�s       r9�test_Generator_linendz'TestMiscellaneous.test_Generator_linend�
s���
�l�W�d�
C�	�q��V�V�X�F�	��N�N�6�4�0�	��'�'��/���J���O�O�%�%�a�(��	�	�	�#���������y�1�	�	�s�B*�*B3c��tddd��5}|j�}ddd�jdd�}tj|�}t�}tjj|�}|j|d��|j|j�jd�|�y#1swY��xYw)NryrVr*rzr�r�r�)r'r�r�r�r�rr�r
r�r2r�rYr|s       r9�test_BytesGenerator_linendz,TestMiscellaneous.test_BytesGenerator_linend�
s���
�l�W�d�
C�	�q��V�V�X�F�	��N�N�6�4�0�	��'�'�	�2���I���O�O�*�*�1�-��	�	�	�#�v�	�&��������,�,�W�5�v�>�	�	�s�B;�;Cc��tdd�5}|j�}ddd�jdd�}|jdd�}tj|�}t�}tjj|�}|j|d��|j|j�|�y#1swY��xYw)	Nryr�swith attachmentsfo��
r�r�r�)r'r�r�r�r�rr�r
r�r2r�r|s       r9�)test_BytesGenerator_linend_with_non_asciiz;TestMiscellaneous.test_BytesGenerator_linend_with_non_ascii�
s���
�l�D�
)�	�Q��V�V�X�F�	���� 2�I�>���N�N�7�E�2�	��&�&�y�1���I���O�O�*�*�1�-��	�	�	�#�v�	�&��������v�.�	�	�s�B<�<Cc�2�tdd�5}|j�}ddd�tdd�5}|j�}ddd�tdftfftfft
t
�fftdftdfg}|D]�\}}|j|jd��5||�}|j|jtjj�ddd�|j|jd��5||d	tjji�}|j|jtjj�ddd���y#1swY��JxYw#1swY��2xYw#1swY��xYw#1swY��xYw)
Nr�r�r�)r+)r&r'ru)�clsr�rxr�)r'r�rrrrrrrr�r�r�r�r�rurx)r6r��	audiodatar��classesr��constructorr�s        r9�!test_mime_classes_policy_argumentz3TestMiscellaneous.test_mime_classes_policy_argument�
sf��
�k�4�
(�	"�B����	�I�	"�
�l�D�
)�	 �R��g�g�i�G�	 ��e�$�
���%�
��
�#�
�7�9�,�'�
�5�6�
�u��

��!(�	>��C�����#�,�,�z��B�
?���%���
�
�a�h�h����(=�(=�>�
?����#�,�,�y��A�
>���B�U�\�\�-A�-A�B���
�
�a�h�h����(<�(<�=�
>�
>�		>�	"�	"��	 �	 ��
?�
?��
>�
>�s/�E&�E3�':F�AF�&E0�3E=�F		�F	N)>r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrr$r(r*r,r6r<r>r@rDrFr%�requires_working_threadingr$�requires_resourcer[r]rbrerirkrnrqrwr�r�r�r�r�r;r9r~r~�sS��	-�
1�6�"6�.��/�
%�J�4�,D�7�6�7�
6�9�C�C�	8�E�K�F�
�/�
	L�L��
��J�6�;�$>�$:�M�3�
�(0�
�"?�'�9�
1��0�0�2��W���u�%�:�&�3�:�&2�@�5�4I�
(�T#�
1�)�	2�	?�
/�>r;r~c�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�
TestIteratorsc�,�|j}|j}|jd�}tj|�}t|�}|t
|�d�|tj|�|j��|jd�}tj|�}t|�}|t
|�d�tdd��5}|tj|�|j��ddd�y#1swYyxYw)Nr�r�rN�+z
msg_19.txtrVr�)r2r	r3r!�body_line_iteratorr�r��EMPTYSTRINGr�rZr'r�)r6r7r�r8�itr�r�s       r9�test_body_line_iteratorz%TestIterators.test_body_line_iterator�
s���
�
�
���#�#���l�l�<�(��
�
)�
)�#�
.���R���
�3�u�:�q���K���U�#�S�_�_�%6�7��l�l�<�(��
�
)�
)�#�
.���R���
�3�u�:�r��
�l�W�
5�	4���� � ��'�����3�	4�	4�	4�s�+D
�
Dc��|j}|jd�}tj|d�}g}d}|D]&}|dz
}|j	|j���(||d�|tj|�d�y)Nryr�rr|r�z`a simple kind of mirror
to reflect upon our own
a simple kind of mirror
to reflect upon our own
�r2r3r!�typed_subpart_iteratorrrZr�r��r6r7r8r�r��subpartsr�s       r9�test_typed_subpart_iteratorz)TestIterators.test_typed_subpart_iterator�
s���
�
�
���l�l�<�(��
�
-�
-�c�6�
:�������	0�G���M�H��L�L��,�,�.�/�	0�	�8�Q��
�;���E�"�%�	r;c��|j}|jd�}tj|dd�}g}d}|D]&}|dz
}|j	|j���(||d�|tj|�d�y)Nr�r�r}rr|z%
Hi,

Do you like this message?

-Me
r�r�s       r9�(test_typed_subpart_iterator_default_typez6TestIterators.test_typed_subpart_iterator_default_type�
s���
�
�
���l�l�<�(��
�
-�
-�c�6�7�
C�������	0�G���M�H��L�L��,�,�.�/�	0�	�8�Q��
�;���E�"�%�	r;c
���gd�}ddlm}m}|�}g}d}|D]`\}}|j|�||z
}d}	t	|j
|�D]}
|j
|
�|	dz
}	�|j||	��b|jt|�|�|jdj|D��cgc]\}}|��	c}}�dj|��ycc}}w)z�FeedParser BufferedSubFile.push() assumed it received complete
           line endings.  A CR ending one push() followed by a LF starting
           the next push() added an empty line.
        ))za
 
r�)r�r)zc
r|)r+r)zd
r|)ze
r)z
fr|)r�r|r��BufferedSubFile�NeedMoreDatar|r+N)
�email.feedparserr�r��push�iter�readlinerr2r�r�)r6�imtr�r��bsf�om�nt�il�n�n1�ols           r9�test_pushCR_LFzTestIterators.test_pushCR_LFs���
	��	C����
��
���	$�E�B���H�H�R�L��!�G�B��B��3�<�<��6�
���	�	�"�
��a���
�
���Q��#�	$�	
����R��"�%�������#�!6���Q�"�!6�7������E��!6s�3Cc�x��ddlm}m}d}d}d�dj�fd�t	|�D��dz}|jd	�}|�}g}t	dt
|�|�D]@}	||	|	|z}
|j|
�|jt|j|���B|j||�y)
Nrr�i'r�zabcd 	
r+c3�4�K�|]}t�����y�wrfr)r>r?�charss  �r9r@z1TestIterators.test_push_random.<locals>.<genexpr>0s�����4�a�F�5�M�4�s�r*T)r�r�r�r�rEr�r�r��extendr�r�r2)r6r�r�r��	chunksizer��targetr�r�r?�chunkr�s           @r9�test_push_randomzTestIterators.test_push_random)s����B����	����G�G�4�5��8�4�4�t�;�����d�#��������q�#�a�&�)�,�	;�A��a��)��$�E��H�H�U�O��L�L��c�l�l�L�9�:�	;�	
�����'r;N)r�r�r�r�r�r�r�r�r�r;r9r�r��
s��4�"�"�&F�<(r;r�c�$�eZdZd�Zd�Zd�Zd�Zy)�TestFeedParsersc�f�t�}|D]}|j|��|j�Srf)r)�feed�close)r6�chunksr�r�s    r9�parsezTestFeedParsers.parse>s3���\�
��	#�E��O�O�E�"�	#����!�!r;c�z�|jd�}|j|dd�|j|dd�y)NzFirst: val
: bad
Second: valr��valr�)r�r2rhs  r9�test_empty_header_name_handledz.TestFeedParsers.test_empty_header_name_handledDs9���j�j�9�:������W��u�-�����X���.r;c���|jdg�}|j|j�gd��|jdg�}|j|j�gd��|jddg�}|j|j�ddg�|jdd	g�}|j|j�dd
g�|jddg�}|j|j�dd
g�|jdg�}|j|j�d
g�|jgd��}|j|j�ddg�y)Nz
a:
b:
c:
d:
)r�r��c�dza:
b:
c:
d:za:
b�c:
r��bc�a:
zb:
r�z
b:
ua:…b:
c:
)r�u	…b:
c:)r�ub:…r��r�r+)r�u…c:)r�r2r�r�r�s  r9�
test_newlineszTestFeedParsers.test_newlinesJs3���J�J�,�-�.���������#7�8��J�J�*�+�,���������#7�8��J�J���(�)���������C��;�/��J�J���'�(���������C��:�.��J�J���)�*���������C��:�.�
�J�J�,�-�.���������%<�$=�>��J�J�1�2���������Y��$@�Ar;c��d\}}|jdgd|zg|zz�}|j|j�dg�|j|j�d|z|z�|jdgd|zg|zz�}|j|j�dg�|j|j�d|z|z�|jdgd|zdzg|zz�}|j|j�dg�|j|j�d|zdz|z�|jddgd|zg|zz�}|j|j�d	d
d|z|zfg�y)N)i�i Nza:b

r�)r�r�za:b

�…r�zb: r�r�)r�r2r�rZ)r6�M�Nr�s    r9�test_long_lineszTestFeedParsers.test_long_lines\s\�����1��J�J�	�{�c�!�e�W�q�[�0�1���������Z�L�1��������#�a�%��'�2��J�J�	�{�c�!�e�W�q�[�0�1���������Z�L�1��������#�a�%��'�2��J�J�	�{�c�!�e�F�l�^�a�%7�7�8���������Z�L�1��������3�q�5��<��*:�;��J�J����#�a�%��1��4�5���������Y��c�!�e�A�g��$?�@r;N)r�r�r�r�r�r�r�r�r;r9r�r�<s��"�/�B�$
Ar;r�c�|�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
dZd
�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�TestParsersc�v�|j}tdd��5}t�j|�}ddd�|dd�||dd�||j	�d�|j|j
��|j|j�t�y#1swY�|xYw)	NrNrVr�r��ppp-request@zzz.orgr��ppp@zzz.orgrk)
r2r'rr�rHrrr�rZr��r6r7r�r8s    r9�test_header_parserzTestParsers.test_header_parserns���
�
�
��
�l�W�
5�	+���.�&�&�r�*�C�	+�
�3�v�;�-�.�
�3�t�9�m�$�
�3���!�#4�5�����)�)�+�,����c�o�o�/��5�
	+�	+�s�B/�/B8c���|j}tdd�5}tjj	�j|�}ddd�|dd�||dd�||j
�d�|j|j��|j|j�t�|j|jd�	�t�y#1swY��xYw)
NrNr�r�r�r�r�rkTrX)
r2r'r�r�r�r�rHrrr�rZr�r�r�s    r9�test_bytes_header_parserz$TestParsers.test_bytes_header_parserys���
�
�
��
�l�D�
)�	=�R��,�,�0�0�2�8�8��<�C�	=�
�3�v�;�-�.�
�3�t�9�m�$�
�3���!�#4�5�����)�)�+�,����c�o�o�/��5����c�o�o�T�o�:�E�B�	=�	=�s�.C(�(C1c�6�tdd��5}|j�}ddd�tjj	tj
j��}|jd��}|j|jg�y#1swY�qxYw)Nz
msg_47.txtrVr�r�T)�headersonly)
r'r�r�r�rr�rxr�r2r�)r6r�r�r��
parsed_msgs     r9�%test_header_parser_multipart_is_validz1TestParsers.test_header_parser_multipart_is_valid�sy��
�l�W�
5�	 ���g�g�i�G�	 ����$�$�E�L�L�,@�,@�$�A���_�_�W�$�_�?�
�����+�+�R�0�
	 �	 �s�B�Bc���tdd�5}tjj�j	|�|j|j�ddd�y#1swYyxYw)NrNr�)r'r�r��BytesParserr�r�closedr�s  r9�%test_bytes_parser_does_not_close_filez1TestParsers.test_bytes_parser_does_not_close_file�sP��
�l�D�
)�	(�R��L�L�$�$�&�,�,�R�0����R�Y�Y�'�	(�	(�	(�s�A	A�A(c�X�tdd�5}tjj}|j	tj
j|tjj��j|�|j|j�ddd�y#1swYyxYw)Nrr�r�)r'r�r�r�r�r r�r��strictr�rr�)r6r��bytesParsers   r9�2test_bytes_parser_on_exception_does_not_close_filez>TestParsers.test_bytes_parser_on_exception_does_not_close_file�s{��
�l�D�
)�	(�R��,�,�2�2�K����e�l�l�F�F�)����1D�1D�E�K�K� �
"�
���R�Y�Y�'�	(�	(�	(�s�B
B � B)c���tdd��5}tjj�j	|�|j|j�ddd�y#1swYyxYw)NrNrVr�)r'r�r�rr�rr�r�s  r9�test_parser_does_not_close_filez+TestParsers.test_parser_does_not_close_file�sP��
�l�W�
5�	(���L�L���!�'�'��+����R�Y�Y�'�	(�	(�	(�s�A	A � A)c�Z�tdd��5}tjj}|j	tj
j|tjj��j|�|j|j�ddd�y#1swYyxYw)NrrVr�r�)r'r�r�rr�r r�r�r�r�rr�)r6r�r�s   r9�,test_parser_on_exception_does_not_close_filez8TestParsers.test_parser_on_exception_does_not_close_file�sy��
�l�W�
5�	(���\�\�(�(�F����e�l�l�F�F�$�E�L�L�,?�,?�@�F�F��
L����R�Y�Y�'�		(�	(�	(�s�B
B!�!B*c��|j}tjd�}||dd�||dd�||j�d�y)Nz�From: aperson@dom.ain
To: bperson@dom.ain
Subject: the next line has a space on it
 
Date: Mon, 8 Apr 2002 15:09:19 -0400
Message-ID: spam

Here's the message body
r��!the next line has a space on it
 r�spam�Here's the message body
�r2r�r�rZr5s   r9�test_whitespace_continuationz(TestParsers.test_whitespace_continuation��V��
�
�
���'�'�	)�	��	�3�y�>�?�@�
�3�|��f�%�
�3�?�?��9�:r;c��|j}tjd�}||dd�||dd�||j�d�y)Nz�From: aperson@dom.ain
To: bperson@dom.ain
Date: Mon, 8 Apr 2002 15:09:19 -0400
Message-ID: spam
Subject: the next line has a space on it
 

Here's the message body
r�r�rr�r�r�r5s   r9�(test_whitespace_continuation_last_headerz4TestParsers.test_whitespace_continuation_last_header�r�r;c��|j}tddd��5}t�j|�}ddd�|t	j��d�|jd�}||j
�d�||j�d�|jd	�}||j
�d
�y#1swY��xYw)NryrVr*rzr�rr?z!Simple email with attachment.

r|zapplication/riscos)r2r'rr�r�rZrH)r6r7r�r8�part1�part2s      r9�test_crlf_separationz TestParsers.test_crlf_separation�s���
�
�
��
�l�W�d�
C�	%�r��(�.�.��$�C�	%�
�3�s��� �!�1�%�����"��
�5�!�!�#�\�2�
�5���� G�H�����"��
�5�!�!�#�%9�:�	%�	%�s�C�Cc�$�tddd��5}|j�}ddd�tj�}t	�}t|�}|j
|d��|j|j�|�y#1swY�gxYw)NryrVr*rzr�r�r�r�s      r9�test_crlf_flattenzTestParsers.test_crlf_flatten�sv��
�l�W�d�
C�	�r��7�7�9�D�	��'�'��-���J���a�L��	�	�	�#�v�	�&��������t�,�
	�	�s�B�BNc���|j}|j}tdd��5}tj|�}ddd�|j�d�|t
|j��d�|jd�}||j�d�||j�d�|t
|j��d�|jd�}||j�d�||j�d�||j�d	�|jd�}||j�d�||j�d�|t
|j��d�|jd�}||j�d�||j�d�||j�d
�y#1swY���xYw)NrarVr�r|r�rrXr?rr )	r2r	r'r�rrr�rZrH)	r6r7r�r�r8r��part1ar��part2as	         r9�-test_multipart_digest_with_extra_mime_headersz9TestParsers.test_multipart_digest_with_extra_mime_headers�s���
�
�
���#�#��
�l�W�
5�	.���)�)�"�-�C�	.�	�3����q�!�
�3�s��� �!�1�%�����"��
�5�!�!�#�%5�6�
�5�����#�
�3�u� � �"�#�Q�'��"�"�1�%��
�6��� �!�$�
�6�"�"�$�l�3��F��� �-�0�����"��
�5�!�!�#�%5�6�
�5�����#�
�3�u� � �"�#�Q�'��"�"�1�%��
�6��� �!�$�
�6�"�"�$�l�3��F��� �-�0�5	.�	.�s�G&�&G0c��gd�}tjtj|��}|j	|dd�y)N)z$From: Andrew Person <aperson@dom.ainz
Subject: Testz%Date: Tue, 20 Aug 2002 16:43:45 +1000�datezTue, 20 Aug 2002 16:43:45 +1000)r�r�r�r�r2)r6r�r8s   r9�test_three_lineszTestParsers.test_three_liness8��:���'�'������7������V��&G�Hr;c��|j}d}d}d|�d|�d�}tj|�}||jd�|�||jd�|�y)Nr�z	more textzHeader: z
Next-Header: z

Body

rzNext-Header)r2r�r��get)r6r7�value1�value2r�r8s      r9�3test_strip_line_feed_and_carriage_return_in_headersz?TestParsers.test_strip_line_feed_and_carriage_return_in_headers
sY��
�
�
�������F�
���'�'��*��
�3�7�7�8��f�%�
�3�7�7�=�!�6�*r;c���|j}d}tj|�}|t|�d�|t	d�|D��gd��||j�d�y)Nz(>From: foo
From: bar
!"#QUX;~: zoo

bodyr�c3� K�|]}|���y�wrfr�)r>�fields  r9r@z9TestParsers.test_rfc2822_header_syntax.<locals>.<genexpr>s����)�E�%�)���)z!"#QUX;~z>Fromr�r�)r2r�r�r�r�rZr�s    r9�test_rfc2822_header_syntaxz&TestParsers.test_rfc2822_header_syntaxsV��
�
�
��:���'�'��*��
�3�s�8�Q��
�6�)�S�)�)�+H�I�
�3�?�?��f�%r;c��|j}d}tj|�}|t|j	��d�y)Nz<>From foo@example.com 11:25:53
From: bar
!"#QUX;~: zoo

bodyr)r2r�r�r�r�r�s    r9�(test_rfc2822_space_not_allowed_in_headerz4TestParsers.test_rfc2822_space_not_allowed_in_headers6��
�
�
��N���'�'��*��
�3�s�x�x�z�?�A�r;c���|j}d}tj|�}|j�}|j	�||gd��||j�d�y)Nz7A: first header
B: second header
CC: third header

body)�A�B�CCr�)r2r�r�r��sortrZ)r6r7r�r8�headerss     r9�!test_rfc2822_one_character_headerz-TestParsers.test_rfc2822_one_character_header#sR��
�
�
��I���'�'��*���(�(�*������
�7�$�%�
�3�?�?��f�%r;c��d}tj|�}|j|jd�j�j	d��y)Nz�From: foo@bar.com
To: baz
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary=BOUNDARY

--BOUNDARY
Content-Type: text/plain

body ending with CRLF newline

--BOUNDARY--
rr�)r�r�r�rZru�r6r�r8s   r9�test_CRLFLF_at_end_of_partz&TestParsers.test_CRLFLF_at_end_of_part,sG��

�	
��'�'��*���������*�6�6�8�A�A�&�I�Jr;)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr�r;r9r�r�lsf��	6�
C�1�(�
(�(�
(�;�$;�$	;�-��G�1�>I�	+�&��&�Kr;r�c	��eZdZejd�Zd�Zd�Zd�Zd�Z	d�Z
d�ZdZd	jeD���cgc]\}}|��	c}}}�d
zjd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zejd�jd�Zd�Zd�Zejd�Zd�Zd�Z d�Z!ejEd	�Z#dge#dd d	je#�Z#d!�Z$ejd"�jd#�Z%ejd$�Z&d%�Z'd&�Z(d'�Z)d(�Z*d)�Z+d*�Z,d+�Z-d,Z.y,cc}}}w)-�Test8BitBytesHandlingz�        From: foo@bar.com
        To: baz
        Mime-Version: 1.0
        Content-Type: text/plain; charset={charset}
        Content-Transfer-Encoding: {cte}

        {bodyline}
        c�*�|jjddd��jd�}tj|�}|j|j
�d�|j|j
d��djd��y)NrVr`�pöstal�rAr��bodyline�pöstal
TrX��bodytest_msgr�r�r�r�r2rZrs   r9�test_known_8bit_CTEz)Test8BitBytesHandling.test_known_8bit_CTESs������$�$�W�)/�.7�
%�
9�9?����	
��&�&�q�)��������*�K�8���������5�$�+�+�G�4�	6r;c�*�|jjddd��jd�}tj|�}|j|j
�d�|j|j
d��d	jd��y)
N�notavalidcharsetr`rrrVup��stal
TrXrrrs   r9�test_unknown_8bit_CTEz+Test8BitBytesHandling.test_unknown_8bit_CTE\s������$�$�-?�)/�.7�
%�
9�9?����	
��&�&�q�)��������*�,A�B���������5�$�+�+�G�4�	6r;c�*�|jjddd��jd�}tj|�}|j|j
�d�|j|j
d��djd��y)	NrVrC�p=C3=B6stálru
p=C3=B6stál
TrX�	pöstál
rrs   r9�test_8bit_in_quopri_bodyz.Test8BitBytesHandling.test_8bit_in_quopri_bodyes���
���$�$�W�);�.<�
%�
>�>D�f�W�o�	
��&�&�q�)��������*�,<�=���������5�%�,�,�W�5�	7r;c�*�|jjddd��jd�}tj|�}|j|j
�d�|j|j
d��d	jd��y)
Nr�rCr!rrVup=C3=B6st��l
TrXr"rrs   r9�.test_invalid_8bit_in_non_8bit_cte_uses_replacezDTest8BitBytesHandling.test_invalid_8bit_in_non_8bit_cte_uses_replacews���
���$�$�W�);�.<�
%�
>�>D�f�W�o�	
��&�&�q�)��������*�,F�G���������5�$�+�+�G�4�	6r;c�D�|jjddd��jd�}tj|�}|j|j
d��djd��|j|jdtj�y)	NrVrWu
cMO2c3RhbAá=rTrXrr)rr�r�r�r�r2rZr�r�r r�rs   r9�test_8bit_in_base64_bodyz.Test8BitBytesHandling.test_8bit_in_base64_body�s���
���$�$�W�)1�.=�
%�
?�?E�v�g��	
��&�&�q�)����������5�"�)�)�'�2�	4����c�k�k�!�n�$�B�B�	Dr;c���|jjddd��jd�}tj|�}|j|j
d��djd��y)NrVr�u
<,.V<W1A; á rTrXu<,.V<W1A; á 
rrs   r9�test_8bit_in_uuencode_bodyz0Test8BitBytesHandling.test_8bit_in_uuencode_body�sn��
���$�$�W�)3�.=�
%�
?�?E�v�g��	
��&�&�q�)����������5�*�1�1�'�:�	<r;))zFrom: foo@bar.com�r�rB)uTo: báz)r�z=?unknown-8bit?q?b=C3=A1z?=)uVSubject: Maintenant je vous présente mon collègue, le pouf célèbre
	Jean de Baddie)r�z�=?unknown-8bit?q?Maintenant_je_vous_pr=C3=A9sente_mon_coll=C3=A8gue=2C_le_pouf_c=C3=A9l=C3=A8bre?=
 =?unknown-8bit?q?_Jean_de_Baddie?=)uFrom: göst)r�z=?unknown-8bit?b?Z8O2c3Q=?=r*z
Yes, they are flying.
rVc���tj|j�}|jt	|jd��d�|jt	|d�d�y)Nr��b��z)r�r��headertest_msgr2r�r�rhs  r9�test_get_8bit_headerz*Test8BitBytesHandling.test_get_8bit_header�sO���&�&�t�':�':�;������S�W�W�T�]�+�-=�>�����S��Y��)9�:r;c��tj|j�}|jt	|�tjd�j|jD��cgc]
\}}|d��c}}��ycc}}w)Nz�                            From: {}
                            To: {}
                            Subject: {}
                            From: {}

                            Yes, they are flying.
                            r|)	r�r�r-r2r�r�r�r��headertest_headers)r6r8�_r�s    r9�test_print_8bit_headersz-Test8BitBytesHandling.test_print_8bit_headers�sw���&�&�t�':�':�;������S��(����* �!�"(��(,�(?�(?�*A�-�1�h�(�1�+�*A�B�		C��*As�#A<c��tj|j�}|j|j	�D�cgc]
}t|���c}gd��ycc}w)N)rBr,�]Maintenant je vous pr��sente mon coll��gue, le pouf c��l��bre
	Jean de Baddie�	g��st)r�r�r-�assertListEqualr�r��r6r8r�s   r9�test_values_with_8bit_headersz3Test8BitBytesHandling.test_values_with_8bit_headers�sE���&�&�t�':�':�;�����c�j�j�l�;��c�!�f�;�2�	3��;s�Ac
���tj|j�}|j|j	�D��cgc]\}}t|�t|�f��c}}gd��ycc}}w)N)r*)r�r,)r�r4)r�r5)r�r�r-r6r�r�)r6r8r�rs    r9�test_items_with_8bit_headersz2Test8BitBytesHandling.test_items_with_8bit_headers�sR���&�&�t�':�':�;�����S�Y�Y�[�I�6�A�q�s�1�v�s�1�v�.�I�<�	=��Is� A*
c��tj|j�}|j|j	d�D�cgc]
}t|���c}ddg�ycc}w)Nr�rBr5)r�r�r-r6r4r�r7s   r9�test_get_all_with_8bit_headersz4Test8BitBytesHandling.test_get_all_with_8bit_headers�sN���&�&�t�':�':�;�����c�k�k�&�.A�B��c�!�f�B�,�0�2�	3��Bs�Ac�2�tjtjd�j	d��}|j|j
�d�|j|j�d�|j|j�d�y)NuA            Content-Type: text/pl§in; charset=utf-8
            r�utext/pl�inr�upl�in)	r�r�r�r�r�r2rHrkrrhs  r9�test_get_content_type_with_8bitz5Test8BitBytesHandling.test_get_content_type_with_8bit�sz���&�&�x���8�(���	�"�$��	
����-�-�/�1B�C�����1�1�3�V�<�����0�0�2�L�Ar;c� �tjdjd��}|j|j	d��gd��|j|jdd��d�|j|jdd��d�y)	Nu(X-Header: foo=§ne; b§r=two; baz=three
r�r
r))r���ne)ub�rrr�Foor@ub§r)r�r�r�r2rrIrhs  r9�test_get_params_with_8bitz/Test8BitBytesHandling.test_get_params_with_8bit�sz���&�&�;�B�B�9�M�O��������z��:�G�	I�������u�Z��@�*�M�������x�
��C�T�Jr;c��tjtjd�j	d��}|j|j
d�d�y)N�n            Content-Type: text/plain; charset=us-ascii;
             title*=us-ascii'en'This%20is%20not%20f§nr��title)rN�enuThis is not f�n)r�r�r�r�r�r2rIrhs  r9�!test_get_rfc2231_params_with_8bitz7Test8BitBytesHandling.test_get_rfc2231_params_with_8bit�sL���&�&�x���8<�(��v�i� �"��	
������w�/�6�	8r;c���tjtjd�j	d��}|jdd�|j
|jd�d�y)NrDr�rE�test)r�r�r�r�r�r0r2rIrhs  r9�!test_set_rfc2231_params_with_8bitz7Test8BitBytesHandling.test_set_rfc2231_params_with_8bit�sW���&�&�x���8<�(��v�i� �"��	�
�
�g�v�&�������w�/��8r;c��tjtjd�j	d��}|jd�|j
|jd�d�|j
|j�d�y)NrDr�rEr�)	r�r�r�r�r�r:r2rIrkrhs  r9�!test_del_rfc2231_params_with_8bitz7Test8BitBytesHandling.test_del_rfc2231_params_with_8bit�sn���&�&�x���8<�(��v�i� �"��	�
�
�g��������w�/��6�����1�1�3�V�<r;c��tjtjd�j	d��}|j|j
�d�|j|j
d��d�y)Nu�            Content-Transfer-Encoding: b§se64
            Content-Type: text/plain; charset=latin-1

            payload
            r�zpayload
TrXspayload
)r�r�r�r�r�r2rZrhs  r9�%test_get_payload_with_8bit_cte_headerz;Test8BitBytesHandling.test_get_payload_with_8bit_cte_headersb���&�&�x���8�(�
��	�"�$��	
������*�K�8���������5�|�Dr;u0        From: foo@bar.com
        To: báz
        Subject: Maintenant je vous présente mon collègue, le pouf célèbre
        	Jean de Baddie
        Mime-Version: 1.0
        Content-Type: text/plain; charset="utf-8"
        Content-Transfer-Encoding: 8bit

        Да, они летят.
        c��tj|j�}t�}tjj|�j
|�|j|j�|j�yrf)	r�r��non_latin_bin_msgrr�r
r�r2r��r6r8r�s   r9�test_bytes_generatorz*Test8BitBytesHandling.test_bytes_generatorsX���&�&�t�'=�'=�>���i��
���&�&�s�+�3�3�C�8���������)?�)?�@r;c���tjj�}t�}tjj|�j
|�|j|j�d�y)Nr�)	r�rnrrr�r
r�r2r�rQs   r9�&test_bytes_generator_handles_None_bodyz<Test8BitBytesHandling.test_bytes_generator_handles_None_body#sN���m�m�#�#�%���i��
���&�&�s�+�3�3�C�8���������/r;a�        From: foo@bar.com
        To: =?unknown-8bit?q?b=C3=A1z?=
        Subject: =?unknown-8bit?q?Maintenant_je_vous_pr=C3=A9sente_mon_coll=C3=A8gue?=
         =?unknown-8bit?q?=2C_le_pouf_c=C3=A9l=C3=A8bre?=
         =?unknown-8bit?q?_Jean_de_Baddie?=
        Mime-Version: 1.0
        Content-Type: text/plain; charset="utf-8"
        Content-Transfer-Encoding: base64

        0JTQsCwg0L7QvdC4INC70LXRgtGP0YIuCg==
        c��tj|j�}t�}tjj|�j
|�|j|j�|j�yrf)
r�r�rPrr�rr�r2r�� non_latin_bin_msg_as7bit_wrappedrQs   r9�test_generator_handles_8bitz1Test8BitBytesHandling.test_generator_handles_8bit7sX���&�&�t�'=�'=�>���j��
���!�!�#�&�.�.�s�3���������)N�)N�Or;c�v�tj|j�}t�}t	|�j|�|j
�}tt��j|�t�}t	|�j|�|j|j
�|�yrf)
r�r�rPrr
r�r�rrr2)r6r8r��
orig_values    r9�;test_str_generator_should_not_mutate_msg_when_handling_8bitzQTest8BitBytesHandling.test_str_generator_should_not_mutate_msg_when_handling_8bit=s����&�&�t�'=�'=�>���i���s��#�#�C�(��\�\�^�
��(�*��%�%�c�*��i���s��#�#�C�(���������4r;c��tj|j�}t�}tjj|�j
|d��|j�jd�}|j|dj�dd�|jdj|dd�|j�y)NTr�r�rsFromr|)r�r�rPrr�r
r�r�r�r2r�)r6r8r�r�s    r9�#test_bytes_generator_with_unix_fromz9Test8BitBytesHandling.test_bytes_generator_with_unix_fromGs����&�&�t�'=�'=�>���i��
���&�&�s�+�3�3�C�$�3�G�����$�$�U�+������q����)�!�,�g�6�������E�!�"�I�.��0F�0F�Gr;zkSubject: =?unknown-8bit?q?Maintenant_je_vous_pr=C3=A9sente_mon_coll=C3=A8gue=2C_le_pouf_c=C3=A9l=C3=A8bre?=r�r�c��d}|jt|�t|d�5}|j|j�ddd�t|d�5}t
jj�j|�}ddd�|jt�|j�y#1swY�qxYw#1swY�;xYw)Nztest.msg�wbr�)�
addCleanupr&�open�writerPr�r�r�r�r2r��non_latin_bin_msg_as7bit)r6r��testfiler�s    r9�test_message_from_binary_filez3Test8BitBytesHandling.test_message_from_binary_fileXs���
�������#�
�"�d�^�	3�x��N�N�4�1�1�2�	3�
�"�d�^�	;�x����(�(�*�0�0��:�A�	;�����Q���!>�!>�?�		3�	3��	;�	;�s�B1�.B=�1B:�=Cu        From: foo@bar.com
        To: Dinsdale
        Subject: Nudge nudge, wink, wink
        Mime-Version: 1.0
        Content-Type: text/plain; charset="latin-1"
        Content-Transfer-Encoding: 8bit

        oh là là, know what I mean, know what I mean?
        r�a         From: foo@bar.com
        To: Dinsdale
        Subject: Nudge nudge, wink, wink
        Mime-Version: 1.0
        Content-Type: text/plain; charset="iso-8859-1"
        Content-Transfer-Encoding: quoted-printable

        oh l=E0 l=E0, know what I mean, know what I mean?
        c��tj|j�}|jt	|�|j
�yrf)r�r��
latin_bin_msgr2r��latin_bin_msg_as7bitr�s  r9�:test_string_generator_reencodes_to_quopri_when_appropriatezPTest8BitBytesHandling.test_string_generator_reencodes_to_quopri_when_appropriatews2���$�$�T�%7�%7�8������Q���!:�!:�;r;c�*�tj|j�}t�}tjj|�j
|�|j|j�|jjd�dz�y)Nr�r*)
r�r�rfrr�rr�r2r�rY)r6r�r�s   r9�)test_decoded_generator_emits_unicode_bodyz?Test8BitBytesHandling.test_decoded_generator_emits_unicode_body{sm���$�$�T�%7�%7�8���j��
���(�(��-�5�5�a�8�	
����������%�%�i�0��5�	7r;c�6�tjj�}tdt	|j
�d�D]#}|j
|j
||dz��%|j�}|jt|�|j�y)NrrA)r�r��BytesFeedParserrEr�rfr�r�r2r�rg)r6�bfpr?r�s    r9�test_bytes_feedparserz+Test8BitBytesHandling.test_bytes_feedparser�s{�����.�.�0���q�#�d�0�0�1�2�6�	1�A��H�H�T�'�'��!�B�$�/�0�	1��I�I�K������Q���!:�!:�;r;c�H�tdd�5}|j�}ddd�tj�}t	�}tj
j
|�}|j|d��|j|j�|�y#1swY�{xYw)Nryr�r�r�)
r'r�r�r�rr�r
r�r2r�r�s      r9r�z'Test8BitBytesHandling.test_crlf_flatten�s��
�l�D�
)�	�R��7�7�9�D�	��&�&�t�,���I���O�O�*�*�1�-��	�	�	�#�v�	�&��������t�,�
	�	�s�B�B!c�*�tjd�jd�}tj|�}t�}tjj|�}|j|�|j|j�|�y)Nuo            Date: Fri, 18 Mar 2011 17:15:43 +0100
            To: foo@example.com
            From: foodwatch-Newsletter <bar@example.com>
            Subject: Aktuelles zu Japan, Klonfleisch und Smiley-System
            Message-ID: <76a486bee62b0d200f33dc2ca08220ad@localhost.localdomain>
            MIME-Version: 1.0
            Content-Type: multipart/alternative;
                    boundary="b1_76a486bee62b0d200f33dc2ca08220ad"

            --b1_76a486bee62b0d200f33dc2ca08220ad
            Content-Type: text/plain; charset="utf-8"
            Content-Transfer-Encoding: 8bit

            Guten Tag, ,

            mit großer Betroffenheit verfolgen auch wir im foodwatch-Team die
            Nachrichten aus Japan.


            --b1_76a486bee62b0d200f33dc2ca08220ad
            Content-Type: text/html; charset="utf-8"
            Content-Transfer-Encoding: 8bit

            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/html4/loose.dtd">
            <html lang="de">
            <head>
                    <title>foodwatch - Newsletter</title>
            </head>
            <body>
              <p>mit gro&szlig;er Betroffenheit verfolgen auch wir im foodwatch-Team
                 die Nachrichten aus Japan.</p>
            </body>
            </html>
            --b1_76a486bee62b0d200f33dc2ca08220ad--

            rV)r�r�r�r�r�rr�r
r�r2r�)r6r�r8r�r�s     r9�test_8bit_multipartz)Test8BitBytesHandling.test_8bit_multipart�st�����%"�%�J����K	�L�&�&�v�.���I���O�O�*�*�1�-��	�	�	�#���������v�.r;c���t�}td�|d<t�}tjj|�}|j
|d��|j|j�d�y)N�žluťoučký kůňr�r�r�s5Subject: =?utf-8?b?xb5sdcWlb3XEjWvDvSBrxa/FiA==?=

)	rrrr�r�r
r�r2r��r6r�r�r�s    r9�'test_bytes_generator_b_encoding_linesepz=Test8BitBytesHandling.test_bytes_generator_b_encoding_linesep�s^���I���3�4��)���I���O�O�*�*�1�-��	�	�	�!�V�	�$����
�J�J�L�H�	Jr;c���t�}td�|d<t�}tjj|�}|j
|d��|j|j�d�y)Nrsr�r�r�z5Subject: =?utf-8?b?xb5sdcWlb3XEjWvDvSBrxa/FiA==?=

)	rrrr�r�rr�r2r�rts    r9�!test_generator_b_encoding_linesepz7Test8BitBytesHandling.test_generator_b_encoding_linesep�s^���I���3�4��)���J���O�O�%�%�a�(��	�	�	�!�V�	�$����
�J�J�L�G�	Ir;N)/r�r�r�r�r�rrrr#r%r'r)r0r�r�r-r.r2r8r:r<r>rBrGrJrLrNrPrRrTrVrWrZr\r�rbrdrfrgrhrjrnr�rqrurwr�)r>�srcr1s000r9rr@s���#�8�?�?�$�
�L�6�6�7�$
6� D�<�	
���i�i�5G� H� H��#�q�� H�I�#�$�%+�V�G�_��;�
C�	3�
=�3�B�K�8�9�=�E�(����
)�

��V�G�_��A�0�(7�x���8�(
�$�P�5�	H� @�E�E�d�K��	8�%9��Q�q�!� $�y�y�)A�B��@�$�H�O�O�	%�	
��V�I�
��+�8�?�?�	,�	
��<�7�<�-�,/�\
J�
I��G��e	!Is�D<rc��eZdZdZd�Zdd�Zy)� BaseTestBytesGeneratorIdempotentNc���t|d�5}|j�}ddd�|jj|j�}tj|�}||fS#1swY�HxYw)Nr�)r'r��normalize_linesep_regex�sub�blinesepr�r�r@s     r9r3z(BaseTestBytesGeneratorIdempotent._msgobj�sd��
�h��
%�	���7�7�9�D�	��+�+�/�/��
�
�t�D���&�&�t�,���D�y��		�	�s�A%�%A.c���t�}tjj|d��}|j	|||j
��|j
||j��y)Nrrq)r�r�)rr�r�r
r�r�r2r�)r6r8r\r�r�r�s      r9rBz,BaseTestBytesGeneratorIdempotent._idempotent�sN���I���O�O�*�*�1�1�*�=��	�	�	�#��$�,�,�	�?�����q�z�z�|�,r;r|)r�r�r�r�r3rBr�r;r9rzrz�s���G��-r;rzc�8�eZdZdZdZejd�Zy)�TestBytesGeneratorIdempotentNLr*r�s\r\nN�r�r�r�r�r~�re�compiler|r�r;r9r�r��s���G��H�(�b�j�j��2�r;r�c�8�eZdZdZdZejd�Zy)� TestBytesGeneratorIdempotentCRLFr�r�s	(?<!\r)\nNr�r�r;r9r�r��s���G��H�(�b�j�j��7�r;r�c�$�eZdZd�Zd�Zd�Zd�Zy)�
TestBase64c	�B�|j}|tjd�ttjdd����td�D]K}|dk(rd}n"|dkrd}n|d	krd
}n|dkrd}n
|dkrd
}nd}|tjd|z�|��My)N�hello�hellor+��eol�rr�r�r��r��r��r�)r2r�
header_lengthr��body_encoderE)r6r7�size�bsizes    r9�test_lenzTestBase64.test_len�s���
�
�
��
�:�#�#�G�,��z�%�%�h�B�7�8�	:��"�I�	<�D����Q�U����Q�U����Q�U����R�U����R�U�%'�U��z�'�'��d�
�3�U�;�	<r;c��|j}|tjd�d�|tjd�d�y)Nr+r;zaGVsbG8=r�)r2rrYr�s  r9�test_decodezTestBase64.test_decodes7��
�
�
��
�:���R� �#�&�
�:���Z�(�(�3r;c�>�|j}|tjd�d�|tjd�d�|tjd�d�|tjdd�	�d
�|tjddd��d
�y)Nr;r+r�z	aGVsbG8=
shello
z	aGVsbG8K
sdxxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx �(rz�eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IA==
r��rr�z�eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IA==
)r2rr�r�s  r9�test_encodezTestBase64.test_encodes���
�
�
��
�:�!�!�#�&��+�
�:�!�!�(�+�\�:�
�:�!�!�*�-�|�<�
�:�!�!�-�B�?�B�	�	�:�!�!�-�B�F�K��	r;c���|j}tj}||d�d�||d�d�||d�d�||dd��d	�||d�d�y)
Nr�z=?iso-8859-1?b?aGVsbG8=?=�hello
worldz!=?iso-8859-1?b?aGVsbG8NCndvcmxk?=�hello
worldz!=?iso-8859-1?b?aGVsbG8Kd29ybGQ=?=rrrJz=?iso-8859-2?b?aGVsbG8=?=)r2rr	)r6r7�hes   r9�test_header_encodezTestBase64.test_header_encode'sj��
�
�
��
�
%�
%��
�2�g�;�3�4�
�2���!D�E�
�2�n��B�C�
�2�g�|�,�.I�J�
�2�n��B�Cr;N)r�r�r�r�r�r�r�r�r;r9r�r��s��<�4�
�,Dr;r�c��eZdZd�Zd�Zd�Zd�Zd�Zd�ZdEd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�ZdEd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d �Z!d!�Z"d"�Z#d#�Z$d$�Z%d%�Z&d&�Z'd'�Z(d(�Z)d)�Z*d*�Z+d+�Z,dFd,�Z-d-�Z.d.�Z/d/�Z0d0�Z1d1�Z2d2�Z3d3�Z4d4�Z5d5�Z6d6�Z7d7�Z8d8�Z9d9�Z:d:�Z;d;�Z<d<�Z=d=�Z>d>�Z?d?�Z@d@�ZAdA�ZBdB�ZCdC�ZDdD�ZEy)G�
TestQuopric�z�ttttd�td�dz�ttd�td�dz�ttd�td�dz�d�d	D���|_td
�D�cgc]}||jvs�|��c}|_t
|j�t
|j
�zd
k(sJ�tttd�td�dz��|_|jjtd
��|jjtd��td
�D�cgc]}||jvs�|��c}|_
t
|j�t
|j�zd
k(sJ�ycc}wcc}w)Nr��zr|r
�Zr��9c3� K�|]}|���y�wrfr�)r>r�s  r9r@z#TestQuopri.setUp.<locals>.<genexpr>:s����!�1�Q�!�rs!*+-/�r,�~r�=)r�rrE�ord�hlit�hnonr��blitr�remove�bnon�r6r�s  r9r�zTestQuopri.setUp3sC�����#�c�(�C��H�q�L�)��#�c�(�C��H�q�L�)��#�c�(�C��H�q�L�)�!��!�	#�$��	�!&�c�
�A�1�a�t�y�y�.@�Q�A��	��4�9�9�~��D�I�I��.�#�5�5���s�3�x��S��A��6�7��	��	�	����T��#��	�	����S��"�!&�c�
�A�1�a�t�y�y�.@�Q�A��	��4�9�9�~��D�I�I��.�#�5�5�5��B��Bs�F3�"F3�"F8�6F8c��|jD]3}|jtj|�dt	|�z��5|j
D]3}|j
tj|�dt	|�z��5y)Nz'Should not be header quopri encoded: %sz#Should be header quopri encoded: %s)r�rr"�header_check�chrr�r�r�s  r9�test_quopri_header_checkz#TestQuopri.test_quopri_header_checkIs|�����	L�A����Z�4�4�Q�7�A�C��F�J�
L�	L����	L�A��O�O�J�3�3�A�6�A�C��F�J�
L�	Lr;c��|jD]3}|jtj|�dt	|�z��5|j
D]3}|j
tj|�dt	|�z��5y)Nz%Should not be body quopri encoded: %sz!Should be body quopri encoded: %s)r�rr"�
body_checkr�r�r�r�s  r9�test_quopri_body_checkz!TestQuopri.test_quopri_body_checkQs|�����	J�A����Z�2�2�1�5�?�#�a�&�H�
J�	J����	J�A��O�O�J�1�1�!�4�?�#�a�&�H�
J�	Jr;c	���|j}|tjd�d�|ttjdd���tjd�dz�|tjd�d�|ttjdd���tjd�dz�|j
D]5}|tjt
|g��dd	t|�z��7|jD]D}|td
�k(r�|tjt
|g��ddt|�z��F|tjd
�d�y)Nr�r��xxxrJrAs
h@e@l@l@o@r�r|zexpected length 1 for %rr,r�zexpected length 3 for %r� )
r2r"r�r�r	r�r�r�r�r��r6r7r�s   r9�test_header_quopri_lenz!TestQuopri.test_header_quopri_lenYs>��
�
�
��
�:�#�#�H�-�q�1�
�3�z�'�'��%�@�A��#�#�H�-�
��	�	�:�#�#�M�2�B�7�
�3�z�'�'�
�u�E�F��#�#�M�2�
��	����	4�A��z�'�'��q�c�
�3�Q�)�C��F�2�
4�	4����	4�A��C��H�}���z�'�'��q�c�
�3�Q�)�C��F�2�
4�		4�	�:�#�#�D�)�1�-r;c��|j}|jD](}|tjt	|g��d��*|j
D](}|tjt	|g��d��*y)Nr|r�)r2r�r"�body_lengthr�r�r�s   r9�test_body_quopri_lenzTestQuopri.test_body_quopri_lenrsi��
�
�
�����	6�A��z�%�%�e�Q�C�j�1�1�5�	6����	6�A��z�%�%�e�Q�C�j�1�1�5�	6r;c��td�D]E}t|�}|jtjtj
|��|��Gy)Nr�)rEr�r2r"r!�quote)r6r�r�s   r9�test_quote_unquote_idempotentz(TestQuopri.test_quote_unquote_idempotentysF���s��	I�A��A��A����Z�/�/�
�0@�0@��0C�D�a�H�	Ir;Nc��|�tj|�}ntj||�}|j||�yrf)r"r	r2)r6r��expected_encoded_headerrA�encoded_headers     r9�_test_header_encodezTestQuopri._test_header_encode~s:���?�'�5�5�f�=�N�'�5�5�f�g�F�N�����)@�Ar;c�(�|jdd�y)Nr;r+�r�r�s r9�test_header_encode_nullz"TestQuopri.test_header_encode_null�s��� � ��b�)r;c�(�|jdd�y)Nr�z=?iso-8859-1?q?hello?=r�r�s r9�test_header_encode_one_wordz&TestQuopri.test_header_encode_one_word�s��� � ��+C�Dr;c�(�|jdd�y)Nshello
worldz=?iso-8859-1?q?hello=0Aworld?=r�r�s r9�test_header_encode_two_linesz'TestQuopri.test_header_encode_two_lines�s��� � �� @�	Br;c�(�|jdd�y)Nshello�therez=?iso-8859-1?q?hello=C7there?=r�r�s r9�test_header_encode_non_asciiz'TestQuopri.test_header_encode_non_ascii�s��� � �!2� @�	Br;c�,�|jddd��y)Nr�z=?iso-8859-2?q?hello?=rrrJr�r�s r9�test_header_encode_alt_charsetz)TestQuopri.test_header_encode_alt_charset�s��� � ��+C�$�	!�	&r;c�R�tj|�}|j||�yrf)r"�
header_decoder2)r6r��expected_decoded_header�decoded_headers    r9�_test_header_decodezTestQuopri._test_header_decode�s#��#�1�1�.�A������)@�Ar;c�(�|jdd�y�Nr+�r�r�s r9�test_header_decode_nullz"TestQuopri.test_header_decode_null�s��� � ��R�(r;c�(�|jdd�y�Nr�r�r�s r9�test_header_decode_one_wordz&TestQuopri.test_header_decode_one_word�s��� � ��'�2r;c�(�|jdd�y)Nz
hello=0Aworldr�r�r�s r9�test_header_decode_two_linesz'TestQuopri.test_header_decode_two_lines�s��� � ��.�Ar;c�(�|jdd�y)Nz
hello=C7thereuhelloÇtherer�r�s r9�test_header_decode_non_asciiz'TestQuopri.test_header_decode_non_ascii�s��� � ��2B�Cr;c�N�|jtjd�d�y)Na=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30�00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)r2r"r�r�s r9�test_header_decode_re_bug_18380z*TestQuopri.test_header_decode_re_bug_18380�s������1�1�+�>�	�Jr;c��|�tj|�}ntj||��}|j||�y)Nr�)r"rYr2)r6�encoded�expected_decodedr��decodeds     r9�_test_decodezTestQuopri._test_decode�s:���;� �'�'��0�G� �'�'��S�9�G�����"2�3r;c�(�|jdd�yr��r�r�s r9�test_decode_null_wordz TestQuopri.test_decode_null_word�������"�b�!r;c�(�|jdd�y)Nr�r*r�r�s r9�test_decode_null_line_null_wordz*TestQuopri.test_decode_null_line_null_word�s�����&�$�'r;c�(�|jdd�yr�r�r�s r9�test_decode_one_wordzTestQuopri.test_decode_one_word�s�����'�7�+r;c�,�|jddd��y)Nr��Xr�r�r�s r9�test_decode_one_word_eolz#TestQuopri.test_decode_one_word_eol�s�����'�7���4r;c�(�|jdd�y�N�hello
�hello
r�r�s r9�test_decode_one_linezTestQuopri.test_decode_one_line�������+�y�1r;c�(�|jdd�y�Nr�r�r�s r9�test_decode_one_line_lfz"TestQuopri.test_decode_one_line_lf�������)�Y�/r;c�(�|jdd�y)Nzhello
r�r�r�s r9�test_decode_one_line_crz"TestQuopri.test_decode_one_line_cr�rr;c�,�|jddd��y)Nr��helloXr�r�r�r�s r9�test_decode_one_line_nlz"TestQuopri.test_decode_one_line_nl�s�����)�X�3��7r;c�,�|jddd��y)Nr�rr�r�r�r�s r9�test_decode_one_line_crnlz$TestQuopri.test_decode_one_line_crnl�s�����+�x�S��9r;c�(�|jdd�y)Nr�r�r�r�s r9�test_decode_one_line_one_wordz(TestQuopri.test_decode_one_line_one_word�s�����*�N�;r;c�,�|jddd��y)Nr��helloXworldr�r�r�r�s r9�!test_decode_one_line_one_word_eolz,TestQuopri.test_decode_one_line_one_word_eol�s�����*�M�s��Cr;c�(�|jdd�y)N�hello
world
�hello
world
r�r�s r9�test_decode_two_linesz TestQuopri.test_decode_two_lines�s�����.�0@�Ar;c�,�|jddd��y)Nr�helloXworldXr�r�r�r�s r9�test_decode_two_lines_eolz$TestQuopri.test_decode_two_lines_eol�s�����.��C��Hr;c�(�|jdd�y)N��SpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamr�r�s r9�test_decode_one_long_linez$TestQuopri.test_decode_one_long_line�s�����,��5r;c�(�|jdd�y)Nr,r+r�r�s r9�test_decode_one_spacez TestQuopri.test_decode_one_space�s�����#�r�"r;c�(�|jdd�y)Nz     r+r�r�s r9�test_decode_multiple_spacesz&TestQuopri.test_decode_multiple_spaces�s�����'�2�&r;c�(�|jdd�y)Nzhello    
r�r�r�s r9�$test_decode_one_line_trailing_spacesz/TestQuopri.test_decode_one_line_trailing_spaces�s�����/�9�5r;c�(�|jdd�y)Nzhello    
world   
rr�r�s r9�%test_decode_two_lines_trailing_spacesz0TestQuopri.test_decode_two_lines_trailing_spaces�s�����5�7G�Hr;c�(�|jdd�y)Nz=22quoted=20words=22z"quoted words"r�r�s r9�test_decode_quoted_wordz"TestQuopri.test_decode_quoted_word�s�����0�2B�Cr;c�(�|jdd�y)Nzab=CD=EF�abÍïr�r�s r9�test_decode_uppercase_quotingz(TestQuopri.test_decode_uppercase_quoting�������*�l�3r;c�(�|jdd�y)Nzab=cd=efr"r�r�s r9�test_decode_lowercase_quotingz(TestQuopri.test_decode_lowercase_quoting�r$r;c�(�|jdd�y)Nzsoft line=
breakzsoft linebreakr�r�s r9�test_decode_soft_line_breakz&TestQuopri.test_decode_soft_line_break�s�����/�1A�Br;c�(�|jdd�y)NzA=1,B=A ==> A+B==2r�r�s r9�test_decode_false_quotingz$TestQuopri.test_decode_false_quoting�s�����.�0D�Er;c��i}|�d}n||d<|�d}n||d<tj|fi|��}|j||�|dk(s|dk(r1|j�D]}|j	t|�|��yy)Nr�rr*r�r�)r"r�r2r�r�r�)r6r��expected_encoded_bodyrr��kwargs�encoded_bodyr�s        r9�_test_encodezTestQuopri._test_encode�s��������J�#-�F�<� ��;��C��F�5�M�!�-�-�d�=�f�=������'<�=��$�;�#��-�%�/�/�1�
<���$�$�S��Y�
�;�
<�(r;c�(�|jdd�yr��r/r�s r9�test_encode_nullzTestQuopri.test_encode_nullr�r;c�(�|jdd�y)Nz

r1r�s r9�test_encode_null_linesz!TestQuopri.test_encode_null_liness�����&�&�)r;c�(�|jdd�yr�r1r�s r9�test_encode_one_linezTestQuopri.test_encode_one_linerr;c�(�|jdd�yr�r1r�s r9�test_encode_one_line_crlfz$TestQuopri.test_encode_one_line_crlfr�r;c�,�|jddd��y)Nr�r�r�r�r1r�s r9�test_encode_one_line_eolz#TestQuopri.test_encode_one_line_eols�����)�[�f��=r;c�h�|jdjd�jd�dd��y)Nuhelloυ
rV�latin1z
hello=CF=85
r�r�)r/r�rYr�s r9�(test_encode_one_line_eol_after_non_asciiz3TestQuopri.test_encode_one_line_eol_after_non_asciis2�����/�0�0��9�@�@��J�+��	�	9r;c�(�|jdd�y)Nr,z=20r1r�s r9�test_encode_one_spacez TestQuopri.test_encode_one_spaces�����#�u�%r;c�(�|jdd�y)Nz 
z=20
r1r�s r9�test_encode_one_line_one_spacez)TestQuopri.test_encode_one_line_one_space"s�����%��)r;c�(�|jdd�y)Nz 
 
z=20
=20
r1r�s r9�test_encode_two_lines_one_spacez*TestQuopri.test_encode_two_lines_one_space*s�����(�L�1r;c�(�|jdd�y)Nzhello   z
hello  =20r1r�s r9�$test_encode_one_word_trailing_spacesz/TestQuopri.test_encode_one_word_trailing_spaces-r$r;c�(�|jdd�y)Nz	hello   
zhello  =20
r1r�s r9�$test_encode_one_line_trailing_spacesz/TestQuopri.test_encode_one_line_trailing_spaces0s�����,��7r;c�(�|jdd�y)Nzhello  	z
hello  =09r1r�s r9�!test_encode_one_word_trailing_tabz,TestQuopri.test_encode_one_word_trailing_tab3s�����+�|�4r;c�(�|jdd�y)Nz	hello  	
zhello  =09
r1r�s r9�!test_encode_one_line_trailing_tabz,TestQuopri.test_encode_one_line_trailing_tab6s�����-��8r;c�,�|jddd��y)N�
abcd 
1234zabcd =

1234r�rr1r�s r9�,test_encode_trailing_space_before_maxlinelenz7TestQuopri.test_encode_trailing_space_before_maxlinelen9s�����-�)9�a��Hr;c�,�|jddd��y)NrMzabcd=
=20
1234r�rr1r�s r9�(test_encode_trailing_space_at_maxlinelenz3TestQuopri.test_encode_trailing_space_at_maxlinelen<������-�);���Jr;c�,�|jddd��y)NrMzabc=
d=20
1234r�rr1r�s r9�,test_encode_trailing_space_beyond_maxlinelenz7TestQuopri.test_encode_trailing_space_beyond_maxlinelen?rQr;c�(�|jdd�y)Nz
 
 
 
 
 
z=20
=20
=20
=20
=20
r1r�s r9�test_encode_whitespace_linesz'TestQuopri.test_encode_whitespace_linesBs�����)�[�1r;c�(�|jdd�y)Nza = bza =3D br1r�s r9�test_encode_quoted_equalsz$TestQuopri.test_encode_quoted_equalsEs�����'�9�-r;c�(�|jdd�y)N�dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzfxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
xxxxxxxxxxxxxxxxxxxxxxxxxr1r�s r9�test_encode_one_long_stringz&TestQuopri.test_encode_one_long_stringHs�����)�%@�Ar;c�(�|jdd�y)Nzexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
zgxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
xxxxxxxxxxxxxxxxxxxxxxxxx
r1r�s r9�test_encode_one_long_linez$TestQuopri.test_encode_one_long_lineKs�����*�,N�Or;c�(�|jdd�y)Nz�xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
z�xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
r1r�s r9�test_encode_one_very_long_linez)TestQuopri.test_encode_one_very_long_lineNs�����*�8�	:r;c�,�|jddd��y)Nz=====z=3D=
=3D=
=3D=
=3D=
=3Dr�rr1r�s r9�test_encode_shortest_maxlinelenz*TestQuopri.test_encode_shortest_maxlinelenRs�����'�#7�A��Fr;c�L�|jt|jddd��y)Nr+r�r)r�rOr/r�s r9� test_encode_maxlinelen_too_smallz+TestQuopri.test_encode_maxlinelen_too_smallUs!�����*�d�&7�&7��R�A��Nr;c�v�|j}|tjd�d�|tjd�d�|tjd�d�|tjdd��d�|tjddd	�
�d�|tjd�d�y)
Nr+r�r�r��dxxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx r�rzjxxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx=
 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxx=
x xxxx xxxx xxxx xxxx=20r�r�zlxxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx=
 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxx=
x xxxx xxxx xxxx xxxx=20zone line

two line)r2r"r�r�s  r9r�zTestQuopri.test_encodeXs���
�
�
��
�:�!�!�"�%�r�*�
�:�!�!�'�*�G�4�
�:�!�!�"2�3�^�D�
�:�!�!�,�2�>�A�	�
	�:�!�!�,�2�6�J��	�
	�:�!�!�#�
��	
r;rf)NN)Fr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr	rrrrrrrrr r#r&r(r*r/r2r4r6r8r:r=r?rArCrErGrIrKrNrPrSrUrWrZr\r^r`rbr�r�r;r9r�r�2sj��6�,L�J�.�26�I�
B�*�E�B�B�&�B�)�3�B�D�K�4�"�(�,�5�2�0�0�8�:�<�D�B�I�6�#�'�6�I�D�4�4�C�F�<�("�*�0�2�>�9�
&�*�2�4�8�5�9�I�K�K�2�.�B�P�:�G�O�
r;r�c�$�eZdZd�Zd�Zd�Zd�Zy)�TestCharsetc�J�ddlm}	|jd=y#t$rYywxYw)NrrJ�fake)r�rA�CHARSETSr�)r6�
CharsetModules  r9�tearDownzTestCharset.tearDownus*��2�	��&�&�v�.���	��	�s�
�	"�"c���|j}td�}||jd�d�d}|jt|j|�td�}||j|�d�y)NrN�Hello World!u¤¢¤¤¤¦¤¨¤ªrVz(=?utf-8?b?wqTCosKkwqTCpMKmwqTCqMKkwqo=?=)r2r
r	r�r)r6r7r�r�s    r9�test_codec_encodeablez!TestCharset.test_codec_encodeable|sc��
�
�
���J���
�1�?�?�>�*�N�;�6�����,�����;��G���
�1�?�?�1��I�Jr;c��|j}td�}|d|jd��td�}|d|jd��td�}|d|jd��td	�}d
dlm}|jd|jdd�td�}|d|jd��y)
Nr=z
hello w=F6rlduhello wörldrVrdr�rNr�rrrJrh)r2r
r�r�rA�add_charset�QP)r6r7r�rjs    r9�test_body_encodezTestCharset.test_body_encode�s���
�
�
���L�!��
�?�A�M�M�*:�;�<��G���
�����~�!>�?��J���
�=�!�-�-�
�6�7��H���	3��!�!�&�-�*:�*:�D�'�J��F�O��
�=�!�-�-�
�6�7r;c��td�}|jt|�d�|jtj
td�y)NrNuascÿii)r
r2r�r�r �CharsetErrorras  r9�test_unicode_charset_namez%TestCharset.test_unicode_charset_name�s8���*�%������W��z�2����&�-�-�w��Dr;N)r�r�r�rkrnrrrur�r;r9rfrfts���	K�8�>Er;rfc��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�
TestHeaderc��|j}td�}||j�d�|jd�||j�d�y)Nrmz Goodbye World!zHello World!  Goodbye World!�r	rr�rr)s   r9�test_simplezTestHeader.test_simple�sE��
�
"�
"���>�"��
�1�8�8�:�~�&�	���"�#�
�1�8�8�:�5�6r;c��|j}td�}||j�d�|jd�||j�d�y)NrmzGoodbye World!zHello World! Goodbye World!ryr)s   r9�test_simple_surprisezTestHeader.test_simple_surprise�sE��
�
"�
"���>�"��
�1�8�8�:�~�&�	���!�"�
�1�8�8�:�4�5r;c�D�d}|jt|�|dfg�y)Nzno decoding neededr�r4s  r9�test_header_needs_no_decodingz(TestHeader.test_header_needs_no_decoding�s"�� ������q�)�Q��I�;�7r;c��tdd��}|jd��jd�D]}|jt	|�d��y)Na�I am the very model of a modern Major-General; I've information vegetable, animal, and mineral; I know the kings of England, and I quote the fights historical from Marathon to Waterloo, in order categorical; I'm very well acquainted, too, with matters mathematical; I understand equations, both the simple and quadratical; about binomial theorem I'm teeming with a lot o' news, with many cheerful facts about the square of the hypotenuse.r�rr,)�
splitcharsz
 )rr�r�r�r�)r6r�ls   r9�	test_longzTestHeader.test_long�sN���L� �
"�����S��)�/�/��6�	-�A�� � ��Q���,�	-r;c�,�|j}td�}td�}td�}d}d}d}t||�}|j||�|j||�|j	d��}	||	d	�t|	�}
|t
|
�d
�||
d|df�||
d|df�||
d
|j	d�df�t|�}||djd��tt|	��}|||�y)Nr=rrrVrrrr�ra=?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerderband_kom?=
 =?iso-8859-1?q?fortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndischen_Wand?=
 =?iso-8859-1?q?gem=E4lden_vorbei=2C_gegen_die_rotierenden_Klingen_bef=F6r?=
 =?iso-8859-1?q?dert=2E_?= =?iso-8859-2?q?Finan=E8ni_metropole_se_hroutily?=
 =?iso-8859-2?q?_pod_tlakem_jejich_d=F9vtipu=2E=2E_?= =?utf-8?b?5q2j56K6?=
 =?utf-8?b?44Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE44G+44Gb44KT44CC?=
 =?utf-8?b?5LiA6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB44GC44Go44Gv44Gn?=
 =?utf-8?b?44Gf44KJ44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CMV2VubiBpc3QgZGFz?=
 =?utf-8?b?IE51bnN0dWNrIGdpdCB1bmQgU2xvdGVybWV5ZXI/IEphISBCZWloZXJodW5k?=
 =?utf-8?b?IGRhcyBPZGVyIGRpZSBGbGlwcGVyd2FsZHQgZ2Vyc3B1dC7jgI3jgajoqIA=?=
 =?utf-8?b?44Gj44Gm44GE44G+44GZ44CC?=r�rr|r�s�Die Mieter treten hier ein werden mit einem Foerderband komfortabel den Korridor entlang, an südlündischen Wandgemälden vorbei, gegen die rotierenden Klingen befördert. Finančni metropole se hroutily pod tlakem jejich důvtipu.. 正確に言うと翻訳はされていません。一部はドイツ語ですが、あとはでたらめです。実際には「Wenn ist das Nunstuck git und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt gersput.」と言っています。)
r	r
rrr�rr�r�rYr)
r6r7r�rrr r!r"r�encr��ustr�newhs
             r9�test_multilingualzTestHeader.test_multilingual�s&��
�
"�
"���L�!��
�\�
"���w���B��$��0�	�
�6�1���	����"��	����D�!��h�h�"�h�%��
�3�)�	*� ��$��
�3�w�<���
�7�1�:���-�.�
�7�1�:���.�/�
�7�1�:�	�(�(��1�7�;�<��1�v��
�4�
D� �f�W�o�#	�&�=��-�.��
�4��r;c�X�t�}|j|j�d�yr�r3r4s  r9�test_empty_header_encodez#TestHeader.test_empty_header_encodes���H���������R�(r;c��|j}t�}||d�|jdtd��||d�y)Nr+r�r=)r	rrr
r)s   r9�test_header_ctor_default_argsz(TestHeader.test_header_ctor_default_args
s9��
�
"�
"���H��
�1�b�	�	������-�.�
�1�e�r;c�b�|j}d}t|�}||j�d�|t|�|�t|d��}||j�d�|t|�|�t|dd��}||j�|�|t|�|�y)Nz|A very long line that must get split to something other than at the 76th character boundary to test the non-default behaviorz}A very long line that must get split to something other than at the 76th
 character boundary to test the non-default behaviorr�rz}A very long line that must get split to something other than at the
 76th character boundary to test the non-default behaviori)rr)r	rr�r�rs    r9�test_explicit_maxlinelenz#TestHeader.test_explicit_maxlinelens���
�
"�
"����
�4�L��
�1�8�8�:�8�	9�	�3�q�6�4���4�Y�/��
�1�8�8�:�=�	>�	�3�q�6�4���4�D�i�@��
�1�8�8�:�t��
�3�q�6�4�r;c
��|j}tdd��}d}|j|�|j�}||d�||t	tt
|����tdd��}|jd�|j�}||d�||t	tt
|����y)Nr=r��rArrda=?iso-8859-1?q?xxx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_?=r�z�=?iso-8859-1?q?xxxx_xxxx_xxxx_xxxx_xxx?=
 =?iso-8859-1?q?x_xxxx_xxxx_xxxx_xxxx_?=
 =?iso-8859-1?q?xxxx_xxxx_xxxx_xxxx_xx?=
 =?iso-8859-1?q?xx_xxxx_xxxx_xxxx_xxxx?=
 =?iso-8859-1?q?_xxxx_xxxx_?=�r	rrr�r�rr�r6r7rr�r�s     r9�test_quopri_splittablez!TestHeader.test_quopri_splittable$s���
�
"�
"���<�B�7����	�����
�H�H�J��
�1�2�2	�f	�1�c�+�m�A�.�/�0�1��<�B�7��	�����
�H�H�J��
�1�!�	"�	�1�c�+�m�A�.�/�0�1r;c
��|j}tdd��}d}|j|�|j�}||d�||t	tt
|����tdd��}|j|�|j�}||d�||t	tt
|����y)Nrsr�r�rda�=?koi8-r?b?eHh4?=
 =?koi8-r?b?eCB4?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?IHh4?=
 =?koi8-r?b?eHgg?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?eCB4?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?IHh4?=
 =?koi8-r?b?eHgg?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?eCB4?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?IHh4?=
 =?koi8-r?b?eHgg?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?eCB4?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?IHh4?=
 =?koi8-r?b?eHgg?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?eCB4?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?IHh4?=
 =?koi8-r?b?eHgg?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?eCB4?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?IHh4?=
 =?koi8-r?b?eHgg?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?eCB4?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?IA==?=r�z�=?koi8-r?b?eHh4eCB4eHh4IHh4eHggeHh4?=
 =?koi8-r?b?eCB4eHh4IHh4eHggeHh4eCB4?=
 =?koi8-r?b?eHh4IHh4eHggeHh4eCB4eHh4?=
 =?koi8-r?b?IHh4eHggeHh4eCB4eHh4IHh4?=
 =?koi8-r?b?eHggeHh4eCB4eHh4IHh4eHgg?=
 =?koi8-r?b?eHh4eCB4eHh4IA==?=r�r�s     r9�test_base64_splittablez!TestHeader.test_base64_splittableis���
�
"�
"���8��3����	�����
�H�H�J��
�1�"�"	�F	�1�c�+�m�A�.�/�0�1��8��3��	�����
�H�H�J��
�1�"�	#�	�1�c�+�m�A�.�/�0�1r;c��|j}d}t|�}||dg�t|�}|||j��y)Nr�)r�N�r2rrr�)r6r7r�r�rs     r9�test_us_ascii_headerzTestHeader.test_us_ascii_header�sB��
�
�
�����!���
�1��� ���N��
�1�a�h�h�j�r;c�f�|j}t�}|jdd�||d�y)Nr�r=)r2rrr)s   r9�test_string_charsetzTestHeader.test_string_charset�s+��
�
�
���H��	����,�'�
�1�g�r;c��|j}tdd�}||j�d�tdd�}||j�d�y)NrrVz=?utf-8?q?p=C3=B6stal?=u菊地時夫z=?utf-8?b?6I+K5Zyw5pmC5aSr?=�r2rr�r)s   r9�test_utf8_shortestzTestHeader.test_utf8_shortest�sH��
�
�
���;��(��
�1�8�8�:�0�1��-�w�7��
�1�8�8�:�5�6r;c�H�|j}|j}d}|tt|�t�}|t|j|�|jdd�}|t
t|d���|�|j	|d��|t
|�|�y)N�0Ynwp4dUEbay Auction Semiar- No Charge � Earn BigrVr�r)r�r2rrrrYr�)r6r=r7r�r�es      r9�test_bad_8bit_headerzTestHeader.test_bad_8bit_header�s����"�"��
�
�
��B���|�V�Q�'��H���|�Q�X�X�q�)�
�H�H�W�i�(��
�3�v�a�	�*�+�Q�/�	����9��%�
�3�q�6�1�
r;c��d}|jdd�}t|tjj��}|jt
|�d�|jtjj|�|dfg�y)Nr�r��surrogateescaperJ�2Ynwp4dUEbay Auction Semiar- No Charge � Earn Big�unknown-8bit)	rYrr�rA�UNKNOWN8BITr2r�r�r)r6r�r�rs    r9�test_escaped_8bit_headerz#TestHeader.test_escaped_8bit_header�sm��B��
�H�H�W�/�0���1�e�m�m�7�7�8������Q��O�	Q�������3�3�A�6�!�^�9L�8M�Nr;c���d}t|tjj��}|j	t|�d�|j	tjj|�|dfg�y�Nr�rJr�r�)rr�rAr�r2r�r�r)r6r�rs   r9�&test_header_handles_binary_unknown8bitz1TestHeader.test_header_handles_binary_unknown8bit�s\��B���1�e�m�m�7�7�8������Q��O�	Q�������3�3�A�6�!�^�9L�8M�Nr;c�d�d}t|tjj��}tjjtjj
|��}|jt|�d�|jtjj
|�|dfg�yr�)	rr�rAr�r�rrr2r�)r6r�r�h2s    r9�+test_make_header_handles_binary_unknown8bitz6TestHeader.test_make_header_handles_binary_unknown8bit�s��B���1�e�m�m�7�7�8��
�\�\�
%�
%�e�l�l�&@�&@��&C�
D������R��O�	Q�������3�3�B�7�1�n�:M�9N�Or;c��td�}tjj|�}|j	d�|jt
|�d�y)NrI)r��test2)rr�r�rrr2r�)r6rr�s   r9�0test_modify_returned_list_does_not_change_headerz;TestHeader.test_modify_returned_list_does_not_change_header�s@���6�N�����+�+�A�.���
�
�(�)�����Q���(r;c��|j}t�}|jdd�|jd�|j�}||d�t	t|��}||j�|�y)Nr�r=�worldz=?iso-8859-1?q?hello?= world)r2rrr�rr)r6r7rr�s    r9� test_encoded_adjacent_nonencodedz+TestHeader.test_encoded_adjacent_nonencoded�sc��
�
�
���H��	����,�'�	�����
�H�H�J��
�1�,�-��
�a�(�)��
�1�8�8�:�q�r;c��|j}d}t|�}||gd��t|�}||j�d�y)NzGSubject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztk=?= =?koi8-r?q?=CA?= zz.))s	Subject: N)s������� � ��������rs)s zz.Nz6Subject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztnK?= zz.r�)r6r7r��parts�hdrs     r9�test_whitespace_keeperz!TestHeader.test_whitespace_keeper�sK��
�
�
��U���a� ��
�5�Y�	Z��%� ��
�3�:�:�<�C�	Er;c�X�|j}d}|tjt|�y)NzXSubject: =?EUC-KR?B?CSixpLDtKSC/7Liuvsax4iC6uLmwMcijIKHaILzSwd/H0SC8+LCjwLsgv7W/+Mj3I ?=)r�r r�r)r6r=r�s   r9�test_broken_base64_headerz$TestHeader.test_broken_base64_header�s$���"�"��f���v�&�&�
�q�9r;c�^�tdd��}|j|j�d�y)Nr1�	shift_jisrJr2r3r4s  r9�test_shift_jis_charsetz!TestHeader.test_shift_jis_charset�s%���5�+�.���������%E�Fr;c�d�tjd�}|jt|�d�y)NzEmptyHeader:zEmptyHeader: 

)r�r�r2r�rhs  r9�!test_flatten_header_with_no_valuez,TestHeader.test_flatten_header_with_no_values)���'�'��7������S��#6�7r;c�X�t�}d|d<|jt|�d�y)Nz   value with leading ws�
SomeHeaderz&SomeHeader:    value with leading ws

)rr2r�rhs  r9�)test_encode_preserves_leading_ws_on_valuez4TestHeader.test_encode_preserves_leading_ws_on_value	s(���i��6��L������S��#M�Nr;c�V�|jtd�j�d�y)Nr,r�r�s r9�test_whitespace_headerz!TestHeader.test_whitespace_headers��������+�+�-�s�3r;N)r�r�r�rzr|r~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r;r9rwrw�s���7�6�8�-�=�~)���&C2�J42�l��7�
�O�O�P�)��E�:�
G�8�O�
4r;rwc��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z y) �TestRFC2231c��|j}|jd�}||jd�d�||jdd��d�y)Nz
msg_29.txtrE�rNrF�%This is even more ***fun*** isn't it!Fr )rNrFz'"This is even more ***fun*** isn't it!")r2r3rIr5s   r9rzTestRFC2231.test_get_paramsM��
�
�
���l�l�<�(��
�3�=�=��!�G�	I�
�3�=�=��%�=�0�I�	Kr;c�`�|j}t�}|jddd��||jd�d�|jdddd��||jd�d�|j	d	�}|jdddd��||jd
��d�y)
NrEr�rNrJ)rNr+r�rF�rA�languager�r�rmrqa"Return-Path: <bbb@zzz.org>
Delivered-To: bbb@zzz.org
Received: by mail.zzz.org (Postfix, from userid 889)
	id 27CEAD38CC; Fri,  4 May 2001 14:05:44 -0400 (EDT)
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Message-ID: <15090.61304.110929.45684@aaa.zzz.org>
From: bbb@ddd.com (John X. Doe)
To: bbb@zzz.org
Subject: This is a test message
Date: Fri, 4 May 2001 14:05:44 -0400
Content-Type: text/plain; charset=us-ascii;
 title*=us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21


Hi,

Do you like this message?

-Me
)r	rr0rIr3r�r5s   r9r1zTestRFC2231.test_set_param s���
�
"�
"���i���
�
�g�G�(�	�	*�
�3�=�=��!�E�	G��
�
�g�G�(�4�	�	9�
�3�=�=��!�G�	I��l�l�<�(���
�
�g�G�(�4�	�	9�
�3�=�=�b�=�)�,�	r;c�
�t�}|jdd�|j|dd�|jddd��|j|dd�|jdd	d��|j|dd
�y)NrEr�r@ztext/plain; title="foo"r
F)�requoteztext/plain; title=barz	(bar)bellztext/plain; title="(bar)bell")rr0r2rhs  r9�test_set_param_requotez"TestRFC2231.test_set_param_requoteEs}���i���
�
�g�u�%�����^�,�.G�H��
�
�g�u�e�
�4�����^�,�.E�F��
�
�g�{�E�
�:�����^�,�.M�Nr;c���|j}|jd�}|jdddd��|jdddd��|jdd	�
�||j	d��d
�y)Nr�r�r
rNrFr�rEr�rDrrmrqa$Return-Path: <bbb@zzz.org>
Delivered-To: bbb@zzz.org
Received: by mail.zzz.org (Postfix, from userid 889)
	id 27CEAD38CC; Fri,  4 May 2001 14:05:44 -0400 (EDT)
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Message-ID: <15090.61304.110929.45684@aaa.zzz.org>
From: bbb@ddd.com (John X. Doe)
To: bbb@zzz.org
Subject: This is a test message
Date: Fri, 4 May 2001 14:05:44 -0400
Content-Type: text/plain; charset="us-ascii";
 title*=us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21


Hi,

Do you like this message?

-Me
)r	r3r0r:r�r5s   r9r<zTestRFC2231.test_del_paramOst��
�
"�
"���l�l�<�(���
�
�e�U�J��
�F��
�
�g�G���	�	/��
�
�e�N�
�3�
�3�=�=�b�=�)�,�	r;c�l�|j}|jd�}||j�d�y)NrbrN)r2r3�get_content_charsetr5s   r9� test_rfc2231_get_content_charsetz,TestRFC2231.test_rfc2231_get_content_charsetps.��
�
�
���l�l�<�(��
�3�"�"�$�j�1r;c���tjd�}tj|�}|j	|j�d�|j	||j
��y)Nz�            Content-Disposition: inline;
            	filename*0*=''This%20is%20even%20more%20;
            	filename*1*=%2A%2A%2Afun%2A%2A%2A%20;
            	filename*2="is it not.pdf"

            �)This is even more ***fun*** is it not.pdf�r�r�r�r�r2rr�rs   r9�test_rfc2231_parse_rfc_quotingz*TestRFC2231.test_rfc2231_parse_rfc_quotingv�Z���O�O��
���'�'��*������)�)�+�D�	F�����C�M�M�O�,r;c���tjd�}tj|�}|j	|j�d�|j	||j
��y)Nz�            Content-Disposition: inline;
            	filename*0*="''This%20is%20even%20more%20";
            	filename*1*="%2A%2A%2Afun%2A%2A%2A%20";
            	filename*2="is it not.pdf"

            r�r�rs   r9� test_rfc2231_parse_extra_quotingz,TestRFC2231.test_rfc2231_parse_extra_quoting�r�r;c��d}tj|�}|jd�}|j|t�|j|d�y)NaContent-Transfer-Encoding: 8bit
Content-Disposition: inline; filename="file____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEMP_nsmail.htm"
Content-Type: text/html; NAME*0=file____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEM; NAME*1=P_nsmail.htm

�NAMEzMfile____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEMP_nsmail.htm�r�r�rI�assertNotIsInstance�tupler2�r6r�r8�params    r9�#test_rfc2231_no_language_or_charsetz/TestRFC2231.test_rfc2231_no_language_or_charset�sN��
���'�'��*���
�
�f�%��� � ���.�����[�	]r;c�r�d}tj|�}|j|j�d�y�Nz�Content-Disposition: inline;
	filename*0*="''This%20is%20even%20more%20";
	filename*1*="%2A%2A%2Afun%2A%2A%2A%20";
	filename*2="is it not.pdf"

r�rrs   r9�/test_rfc2231_no_language_or_charset_in_filenamez;TestRFC2231.test_rfc2231_no_language_or_charset_in_filename��8��
���'�'��*������)�)�+�D�	Fr;c�r�d}tj|�}|j|j�d�yr�rrs   r9�7test_rfc2231_no_language_or_charset_in_filename_encodedzCTestRFC2231.test_rfc2231_no_language_or_charset_in_filename_encoded�r�r;c�r�d}tj|�}|j|j�d�y)Nz�Content-Disposition: inline;
	filename*0="''This%20is%20even%20more%20";
	filename*1*="%2A%2A%2Afun%2A%2A%2A%20";
	filename*2="is it not.pdf"

z1This%20is%20even%20more%20***fun*** is it not.pdfrrs   r9�test_rfc2231_partly_encodedz'TestRFC2231.test_rfc2231_partly_encoded�s9��
���'�'��*���������?�	Ar;c�r�d}tj|�}|j|j�d�y)Nz�Content-Disposition: inline;
	filename*0="This%20is%20even%20more%20";
	filename*1="%2A%2A%2Afun%2A%2A%2A%20";
	filename*2="is it not.pdf"

z?This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20is it not.pdfrrs   r9�test_rfc2231_partly_nonencodedz*TestRFC2231.test_rfc2231_partly_nonencoded�s9��
���'�'��*���������M�	Or;c�r�d}tj|�}|j|j�d�y)Nz�Content-Type: multipart/alternative;
	boundary*0*="''This%20is%20even%20more%20";
	boundary*1*="%2A%2A%2Afun%2A%2A%2A%20";
	boundary*2="is it not.pdf"

r�rrs   r9�/test_rfc2231_no_language_or_charset_in_boundaryz;TestRFC2231.test_rfc2231_no_language_or_charset_in_boundary�r�r;c�r�d}tj|�}|j|j�d�y)Nz�Content-Type: text/plain;
	charset*0*="This%20is%20even%20more%20";
	charset*1*="%2A%2A%2Afun%2A%2A%2A%20";
	charset*2="is it not.pdf"

z)this is even more ***fun*** is it not.pdf�r�r�r2r�rs   r9�.test_rfc2231_no_language_or_charset_in_charsetz:TestRFC2231.test_rfc2231_no_language_or_charset_in_charset�s8��
���'�'��*������0�0�2�D�	Fr;c�r�d}tj|�}|j|j�d�y)Nz�Content-Disposition: inline;
	filename*0*="bogus'xx'This%20is%20even%20more%20";
	filename*1*="%2A%2A%2Afun%2A%2A%2A%20";
	filename*2="is it not.pdf"

r�rrs   r9�%test_rfc2231_bad_encoding_in_filenamez1TestRFC2231.test_rfc2231_bad_encoding_in_filename�r�r;c�r�d}tj|�}|j|j�d�y)Nz:Content-Type: text/plain; charset*=bogus''utf-8%E2%80%9D

r�rs   r9�$test_rfc2231_bad_encoding_in_charsetz0TestRFC2231.test_rfc2231_bad_encoding_in_charset��6��
���'�'��*��	
����0�0�2�D�9r;c�r�d}tj|�}|j|j�d�y)Nz:Content-Type: text/plain; charset*=ascii''utf-8%E2%80%9D

r�rs   r9�%test_rfc2231_bad_character_in_charsetz1TestRFC2231.test_rfc2231_bad_character_in_charsetr�r;c�r�d}tj|�}|j|j�d�y)Nz�Content-Disposition: inline;
	filename*0*="ascii'xx'This%20is%20even%20more%20";
	filename*1*="%2A%2A%2Afun%2A%2A%2A%20";
	filename*2*="is it not.pdf%E2"

u,This is even more ***fun*** is it not.pdf�rrs   r9�&test_rfc2231_bad_character_in_filenamez2TestRFC2231.test_rfc2231_bad_character_in_filenames8��
���'�'��*������)�)�+�J�	Lr;c�r�d}tj|�}|j|j�d�y)Nz^Content-Transfer-Encoding: 8bit
Content-Disposition: inline; filename*=X-UNKNOWN''myfile.txt

�
myfile.txtrrs   r9�test_rfc2231_unknown_encodingz)TestRFC2231.test_rfc2231_unknown_encoding�4��
��
�'�'��*������)�)�+�\�:r;c�r�d}tj|�}|j|j�d�y)NucContent-Transfer-Encoding: 8bit
Content-Disposition: inline; filename*=utf-8���''myfile.txt

r�rrs   r9�&test_rfc2231_bad_character_in_encodingz2TestRFC2231.test_rfc2231_bad_character_in_encoding'r�r;c��|j}d}tj|�}|jd�\}}}||d�||d�||d�y)NzJContent-Type: application/x-foo;
	name*0*="Frank's"; name*1*=" Document"

r�Frank's Documentr�r6r7r�r8rAr�r�s       r9�-test_rfc2231_single_tick_in_filename_extendedz9TestRFC2231.test_rfc2231_single_tick_in_filename_extended0sZ��
�
�
��
��
�'�'��*��"�}�}�V�4����1�
�7�D��
�8�T��
�1� �!r;c��d}tj|�}|jd�}|j|t�|j|d�y)NzGContent-Type: application/x-foo; name*0="Frank's"; name*1=" Document"

rrr�r�s    r9�$test_rfc2231_single_tick_in_filenamez0TestRFC2231.test_rfc2231_single_tick_in_filename>sJ��
���'�'��*���
�
�f�%��� � ���.����� 2�3r;c�r�d}tj|�}|j|j�d�y)NzAContent-Disposition: inline;
	filename*0*="'This%20is%20broken";
z'This is brokenrrs   r9�test_rfc2231_missing_tickz%TestRFC2231.test_rfc2231_missing_tickHs8��
���'�'��*����������	r;c�r�d}tj|�}|j|j�d�y)NzAContent-Disposition: inline;
	filename*0*="'This%20is%E2broken";
u'This is�brokenrrs   r9�0test_rfc2231_missing_tick_with_encoded_non_asciiz<TestRFC2231.test_rfc2231_missing_tick_with_encoded_non_asciiRs8��
���'�'��*���������"�	$r;c��|j}d}tj|�}|jd�\}}}||d�||d�||d�y)NzYContent-Type: application/x-foo;
	name*0*="us-ascii'en-us'Frank's"; name*1*=" Document"

rrN�en-usrrrs       r9�!test_rfc2231_tick_attack_extendedz-TestRFC2231.test_rfc2231_tick_attack_extended]sZ��
�
�
��
��
�'�'��*��"�}�}�V�4����1�
�7�J��
�8�W��
�1� �!r;c��d}tj|�}|jd�}|j|t�|j|d�y)NzWContent-Type: application/x-foo;
	name*0="us-ascii'en-us'Frank's"; name*1=" Document"

rzus-ascii'en-us'Frank's Documentr�r�s    r9�test_rfc2231_tick_attackz$TestRFC2231.test_rfc2231_tick_attackksJ��
��
�'�'��*���
�
�f�%��� � ���.����� A�Br;c�z�|j}d}tj|�}||jd�d�y)Nz:Content-Type: application/x-foo; name="Frank's Document"

rrrr�s    r9�test_rfc2231_no_extended_valuesz+TestRFC2231.test_rfc2231_no_extended_valuesws:��
�
�
��
���'�'��*��
�3�=�=�� �"4�5r;c��|j}d}tj|�}|jd�\}}}||d�||d�||d�y)NziContent-Type: application/x-foo;
	name*0*="us-ascii'en-us'My";
	name*1=" Document";
	name*2*=" For You"

rrNr
�My Document For Yourrs       r9�,test_rfc2231_encoded_then_unencoded_segmentsz8TestRFC2231.test_rfc2231_encoded_then_unencoded_segments��Z��
�
�
��
���'�'��*��"�}�}�V�4����1�
�7�J��
�8�W��
�1�#�$r;c��|j}d}tj|�}|jd�\}}}||d�||d�||d�y)NziContent-Type: application/x-foo;
	name*0="us-ascii'en-us'My";
	name*1*=" Document";
	name*2*=" For You"

rrNr
rrrs       r9�,test_rfc2231_unencoded_then_encoded_segmentsz8TestRFC2231.test_rfc2231_unencoded_then_encoded_segments�rr;c��ddg}|D]2}|j|��5tj|�}ddd��4y#1swY�?xYw)Nz�From: user@host.com
To: user@host.com
Bad-Header:
 =?us-ascii?Q?LCSwrV11+IB0rSbSker+M9vWR7wEDSuGqmHD89Gt=ea0nJFSaiz4vX3XMJPT4vrE?=
 =?us-ascii?Q?xGUZeOnp0o22pLBB7CYLH74Js=wOlK6Tfru2U47qR?=
 =?us-ascii?Q?72OfyEY2p2=2FrA9xNFyvH+fBTCmazxwzF8nGkK6D?=

Hello!
u�From: ����� �������� <xxx@xxx>
To: "xxx" <xxx@xxx>
Subject:   ��� ���������� ����� ����� � ��������� �� ����
MIME-Version: 1.0
Content-Type: text/plain; charset="windows-1251";
Content-Transfer-Encoding: 8bit

�� ����� � ���� ������ ��� ��������
)r�)r�r�r�)r6�messagesr�r8s    r9�+test_should_not_hang_on_invalid_ew_messagesz7TestRFC2231.test_should_not_hang_on_invalid_ew_messages�s\������"�	3�A������"�
3��/�/��2��
3�
3�	3�
3�
3�s	�=�A	N)!r�r�r�rr1r�r<r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr
rrrrr�r;r9r�r�s���K�#�JO��B2�-�-� ]�
F�
F�A�O�
F�F�
F�:�:�
L�;�;�"�4��$�"�	C�6�
%�"
%�3r;r�c�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�
TestSignedc��t|d��5}|j�}tj|�}ddd�||fS#1swYfSxYwr>r?)r6rBr��originalr8s     r9�_msg_and_objzTestSigned._msg_and_obj�sQ��
�h��
1�	6�R��w�w�y�H��+�+�H�5�C�	6���}��	6���}��s�&A�Ac��ddl}|jd|j|jz�}|j	|�jd�}|j	|�jd�}|j
||�y)Nrz^--([^\n]+)\n(.*?)\n--\1$r�)r�r��Sr��search�groupr2)r6r�resultr��repart�inpart�outparts       r9�_signed_parts_eqzTestSigned._signed_parts_eq�sf�������8�"�$�$����+�F�����x�(�.�.�q�1���-�-��'�-�-�a�0������&�)r;c�p�|jd�\}}|j�}|j||�yrp�rr�r&�r6rr8r"s    r9�test_long_headers_as_stringz&TestSigned.test_long_headers_as_string�s1���)�)�,�7�
��#���������h��/r;c�t�|jd�\}}|jd��}|j||�y)Nrq�<rqr(r)s    r9�(test_long_headers_as_string_maxheaderlenz3TestSigned.test_long_headers_as_string_maxheaderlen�s6���)�)�,�7�
��#����B��/�����h��/r;c��|jd�\}}t�}t|�j|�|j	�}|j||�yrp)rrrr�r�r&)r6rr8r�r"s     r9�test_long_headers_flattenz$TestSigned.test_long_headers_flatten�sJ���)�)�,�7�
��#�
�Z���"�
���c�"���������h��/r;N)r�r�r�rr&r*r-r/r�r;r9rr�s���*�0�
0�
0r;rc��eZdZd�Zy)�TestHeaderRegistryc��t�}|dd�}|j|jdtj�y)Nr>zattachment; 0*00="foo"r)rr�r�r �InvalidHeaderDefect)r6�regr�s   r9�test_HeaderRegistryz&TestHeaderRegistry.test_HeaderRegistry�s6������%�'?�@�����a�i�i��l�F�,F�,F�Gr;N)r�r�r�r5r�r;r9r1r1�s��Hr;r1�__main__)fr�r.rWr!r��iorr�	itertoolsr�randomr�	threadingr�
unittest.mockr	r��email.policy�
email.charsetr
�email.generatorrrr
�email.headerrrr�email.headerregistryr�
email.messager�email.mime.applicationr�email.mime.audior�email.mime.baser�email.mime.imager�email.mime.messager�email.mime.multipartr�email.mime.nonmultipartr�email.mime.textr�email.parserrrrrr r!r"r#rIr$�test.supportr%�test.support.os_helperr&�test.test_emailr'r(r)r�r�rDr.�TestCaser�rr�r�r�r�rr$r{r�r�r6r<r~r�r�r�rrzr�r�r�r�rfrwr�rr1r��mainr�r;r9�<module>rPs���

��
��� �������!�G�G�;�;�/�!�2�&�$�&�*�.�4�$�-��������)�)�3�$�	������c�]�c�N?�8�$�$�?�Fx>�m�x>�zK/�x�(�(�K/�^/D�H�%�%�/D�h7D�H�%�%�7D�vXC�(�+�+�XC�x7A�8�$�$�7A�x~6�M�~6�BkK�
�kK�^}<�-�}<�BsK�m�sK�n		J�}�	J�"Z-�]�Z-�~D	>�
�D	>�Pd(�M�d(�N-A�m�-A�`QK�-�QK�h[�M�[�|-�-�$3�%E�$2�3�8�'G�'5�8�1D��"�"�1D�h}
��"�"�}
�D
5E�(�#�#�5E�ta4��a4�La3�-�a3�N
0��0�BH��H��z���H�M�M�O�r;