+
    BiaH                         ^ RI t ^ RIt^ RIt^ RIHtHt ^ RIHt ^ RIH	t	H
t
 ^ RIHt ^ RIHt ^ RIt^ RIHtHt ] ! R R	4      4       t ! R
 R]]4      t ! R R]]4      t]R8X  d   ]P,                  ! 4        R# R# )    N)message_from_stringmessage_from_bytes)EmailMessage)	GeneratorBytesGenerator)Addresspolicy)TestEmailBaseparameterizec                     a ] tR t^t o]P
                  tRR lt^ ]P                  ! R4      ^(]P                  ! R4      ^]P                  ! R4      /t	]	^ ,          ]	^d&   ]	P                  4       tR]^ &   R]^d&   ]	 U u. uF  q NK  	  up tR tR	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tRtVtR# u up i )TestGeneratorBaseNc                J    Vf   V P                   MTpV P                  WR7      # )Nr	   )r
   msgfunc)selfmsgr
   s   &&&5/usr/lib/python3.14/test/test_email/test_generator.pymsgmakerTestGeneratorBase.msgmaker   s"     &F||C|//    af              To: whom_it_may_concern@example.com
            From: nobody_you_want_to_know@example.com
            Subject: We the willing led by the unknowing are doing the
             impossible for the ungrateful. We have done so much for so long with so little
             we are now qualified to do anything with nothing.

            None
            a              To: whom_it_may_concern@example.com
            From:
             nobody_you_want_to_know@example.com
            Subject: We the willing led by the
             unknowing are doing the impossible for
             the ungrateful. We have done so much
             for so long with so little we are now
             qualified to do anything with nothing.

            None
            a              To:
             whom_it_may_concern@example.com
            From:
             nobody_you_want_to_know@example.com
            Subject: We the
             willing led by the
             unknowing are doing
             the impossible for
             the ungrateful. We
             have done so much
             for so long with so
             little we are now
             qualified to do
             anything with
             nothing.

            None
            a  To: whom_it_may_concern@example.com
From: nobody_you_want_to_know@example.com
Subject: We the willing led by the unknowing are doing the impossible for the ungrateful. We have done so much for so long with so little we are now qualified to do anything with nothing.

None
a  To: whom_it_may_concern@example.com
From: nobody_you_want_to_know@example.com
Subject: We the willing led by the unknowing are doing the impossible for the ungrateful. We have
 done so much for so long with so little we are now qualified to do anything with nothing.

None
c                d   V P                  V P                  V P                  ^ ,          4      4      pV P                  4       pV P	                  W1V P
                  R7      pVP                  V4       V P                  VP                  4       V P                  V P                  V,          4      4       R# )r   maxheaderlenr
   N)	r   typrefold_long_expectedioclassgenclassr
   flattenassertEqualgetvaluer   nr   sgs   &&   r    length_as_maxheaderlen_parameter2TestGeneratorBase.length_as_maxheaderlen_parameterX   sz    mmDHHT%>%>q%ABCLLNMM!DKKM@			#txx0I0I!0L'MNr   c                   V P                  V P                  V P                  ^ ,          4      4      pV P                  4       pV P	                  W0P
                  P                  VR7      R7      pVP                  V4       V P                  VP                  4       V P                  V P                  V,          4      4       R# )r   max_line_lengthr	   N
r   r   r   r   r   r
   cloner   r   r    r!   s   &&   r    length_as_max_line_length_policy2TestGeneratorBase.length_as_max_line_length_policy_   s    mmDHHT%>%>q%ABCLLNMM!KK$5$5a$5$HMI			#txx0I0I!0L'MNr   c                   V P                  V P                  V P                  ^ ,          4      4      pV P                  4       pV P	                  W1V P
                  P                  ^
R7      R7      pVP                  V4       V P                  VP                  4       V P                  V P                  V,          4      4       R# )r   r(   r   Nr*   r!   s   &&   r   ,length_as_maxheaderlen_parm_overrides_policy>TestGeneratorBase.length_as_maxheaderlen_parm_overrides_policyf   s    mmDHHT%>%>q%ABCLLNMM!!%!2!22!2!F  H			#txx0I0I!0L'MNr   c                   V P                  V P                  V P                  ^ ,          4      4      pV P                  4       pV P	                  W0P
                  P                  RVR7      R7      pVP                  V4       V P                  VP                  4       V P                  V P                  ^ ,          4      4       R# )r   nonerefold_sourcer)   r	   Nr*   r!   s   &&   r   8length_as_max_line_length_with_refold_none_does_not_foldJTestGeneratorBase.length_as_max_line_length_with_refold_none_does_not_foldn   s    mmDHHT%>%>q%ABCLLNMM!KK$5$5FFG %6 %IM J			#txx0I0I!0L'MNr   c                   V P                  V P                  V P                  ^ ,          4      4      pV P                  4       pV P	                  W0P
                  P                  RVR7      R7      pVP                  V4       V P                  VP                  4       V P                  V P                  V,          4      4       R# )r   allr3   r	   N)r   r   r   r   r   r
   r+   r   r   r    refold_all_expectedr!   s   &&   r   /length_as_max_line_length_with_refold_all_foldsATestGeneratorBase.length_as_max_line_length_with_refold_all_foldsv   s    mmDHHT%>%>q%ABCLLNMM!KK$5$5EFG %6 %IM J			#txx0H0H0K'LMr   c                0   R pTpV P                  V P                  V4      4      pV P                  4       pV P                  V\        P
                  R7      pVP                  V4       V P                  VP                  4       V P                  V4      4       R# )zSubject: test

test body
r	   N	r   r   r   r   r
   SMTPr   r   r    r   sourceexpectedr   r#   r$   s   &     r   test_crlf_control_via_policy.TestGeneratorBase.test_crlf_control_via_policy~   sn    5mmDHHV,-LLNMM!FKKM0			#txx'9:r   c                4   R pTpV P                  V P                  V4      4      pV P                  4       pV P                  V\        P
                  R7      pVP                  VRR7       V P                  VP                  4       V P                  V4      4       R# )zSubject: test

test body
r	   
)linesepNr=   r?   s   &     r   %test_flatten_linesep_overrides_policy7TestGeneratorBase.test_flatten_linesep_overrides_policy   ss    /mmDHHV,-LLNMM!FKKM0			#t	$txx'9:r   c                >   R pV P                  V P                  V4      4      pV P                  VR,          R4       RpV P                  4       pV P	                  V4      pVP                  V4       V P                  VP                  4       V P                  V4      4       RpV P                  4       pV P	                  W@P                  P                  RR7      R7      pVP                  V4       V P                  VP                  4       V P                  V4      4       R# )	z.Subject: one
 two three
 four

test body
Subjectzone two three fourz*Subject: one
 two
 three
 four

test body
z'Subject: one two three four

test body
r8   r4   r	   N	r   r   r   r   r   r   r    r
   r+   r   r@   r   rA   r#   r$   s   &     r   test_flatten_linesep&TestGeneratorBase.test_flatten_linesep   s    KmmDHHV,-Y)=>ELLNMM!			#txx'9:?LLNMM!KK$5$5E$5$JMK			#txx'9:r   c                :   R pV P                  V P                  V4      4      pV P                  VR,          R4       RpV P                  4       pV P	                  V4      pVP                  V4       V P                  VP                  4       V P                  V4      4       V P                  4       pV P	                  W@P                  P                  RR7      R7      pVP                  V4       V P                  VP                  4       V P                  V4      4       R# )z8Subject: one two three four five six

test body
rJ   z one two three four five sixz5Subject: one two three four five six

test body
r8   rK   r	   NrL   rM   s   &     r   test_flatten_control_linesep.TestGeneratorBase.test_flatten_control_linesep   s    \mmDHHV,-Y)VWXLLNMM!			#txx'9:LLNMM!KK$5$5E$5$JMK			#txx'9:r   c           	     ~   \         P                  ! R 4      pR	\        P                  R3\        P                  R3\        P                  P                  RR7      R33pV F  w  r4V'       d   VP                  RR4      MTpV P                  W4R7      ;_uu_ 4        V P                  V P                  V4      4      pV P                  4       pV P                  WsR7      pVP                  V4       V P                  VP                  4       V P                  V4      4       RRR4       K  	  R#   + '       g   i     K  ; i)
z            Subject: test that
             from is mangled in the body!

            From time to time I write a rhyme.
            NTF)mangle_from_zFrom z>From )r
   rT   r	   )NT)textwrapdedentr
   compat32defaultr+   replacesubTestr   r   r   r   r   r   r    )	r   r@   variantspmanglerA   r   r#   r$   s	   &        r   test_set_mangle_from_via_policy1TestGeneratorBase.test_set_mangle_from_via_policy   s     "  __d#^^U#^^!!t!4d;	 "IA<Bv~~gx8HQ<<mmDHHV$45LLNMM!M.		#  txx/AB =< "<<<s   BD++D<c                   V P                  V P                  V P                  ^ ,          4      4      pV P                  4       pV P	                  V\
        P                  P                  RR7      R7      pVP                  V4       V P                  VP                  4       V P                  V P                  ^ ,          4      4       R# )r   Nr(   r	   )r   r   r   r   r   r
   rW   r+   r   r   r    )r   r   r#   r$   s   &   r   5test_compat32_max_line_length_does_not_fold_when_noneGTestGeneratorBase.test_compat32_max_line_length_does_not_fold_when_none   s    mmDHHT%>%>q%ABCLLNMM!FOO$9$9$$9$OMP			#txx0I0I!0L'MNr   c                   V P                  V P                  \        P                  ! R 4      4      4      p\        P                  ! R4      pV P	                  4       pV P                  W0P                  P                  ^!R7      R7      pVP                  V4       V P                  VP                  4       V P                  V4      4       R# )            To: nobody
            Content-Disposition: attachment;
             filename="afilenamelongenoghtowraphere"

            None
            z            To: nobody
            Content-Disposition: attachment;
             filename*0*=us-ascii''afilename;
             filename*1*=longenoghtowraphere

            None
            r(   r	   Nr   r   rU   rV   r   r   r
   r+   r   r   r    r   r   rA   r#   r$   s   &    r   test_rfc2231_wrapping'TestGeneratorBase.test_rfc2231_wrapping   s     mmDHHX__ 6 &   ?? $  LLNMM!KK$5$5b$5$IMJ			#txx'9:r   c                   V P                  V P                  \        P                  ! R 4      4      4      p\        P                  ! R4      pV P	                  4       pV P                  W0P                  P                  ^R7      R7      pVP                  V4       V P                  VP                  4       V P                  V4      4       R# )rd   z            To: nobody
            Content-Disposition:
             attachment;
             filename*0*=us-ascii''afilenamelongenoghtowraphere

            None
            r(   r	   Nre   rf   s   &    r   ;test_rfc2231_wrapping_switches_to_default_len_if_too_narrowMTestGeneratorBase.test_rfc2231_wrapping_switches_to_default_len_if_too_narrow   s     mmDHHX__ 6 &   ?? $  LLNMM!KK$5$5b$5$IMJ			#txx'9:r   c                   V P                  V P                  \        P                  ! R 4      4      4      p\        P                  ! R 4      pV P	                  4       pV P                  W0P                  P                  ^PR7      R7      pVP                  V4       V P                  VP                  4       V P                  V4      4       R# )            To: nobody
            Subject: Bad subject=?UTF-8?Q?=0A?=Bcc: injection@example.com

            None
            r(   r	   Nre   rf   s   &    r   test_keep_encoded_newlines,TestGeneratorBase.test_keep_encoded_newlines   s    mmDHHX__ 6 &   ?? $  LLNMM!KK$5$5b$5$IMJ			#txx'9:r   c                   V P                  V P                  \        P                  ! R 4      4      4      p\        P                  ! R4      pV P	                  4       pV P                  W0P                  P                  ^R7      R7      pVP                  V4       V P                  VP                  4       V P                  V4      4       R# )rm   z            To: nobody
            Subject: Bad subject
             =?utf-8?q?=0A?=Bcc:
             injection@example.com

            None
            r(   r	   Nre   rf   s   &    r   test_keep_long_encoded_newlines1TestGeneratorBase.test_keep_long_encoded_newlines  s    mmDHHX__ 6 &   ?? $  LLNMM!KK$5$5b$5$IMJ			#txx'9:r    N)__name__
__module____qualname____firstlineno__r
   rX   r   rU   rV   r   copyr9   length_paramsr%   r,   r/   r5   r:   rB   rG   rN   rQ   r^   ra   rg   rj   rn   rq   __static_attributes____classdictcell__)r"   __classdict__s   0@r   r   r      s     ^^F0
 	
8??   	HOO   	HOO  -)
T !5Q 7.335   !55 41Q 45MOOOON;;;"; C,O;.;0;$; ;s 6s   =
B=r   c                   \   a  ] tR tRt o ]! ]4      t]t]	P                  t]tR tR tRtV tR# )TestGeneratori$  c                :   R pV P                  V P                  V4      4      pV P                  VR,          R4       RpV P                  4       pV P	                  V4      pVP                  V4       V P                  VP                  4       V P                  V4      4       V P                  4       pV P	                  W@P                  P                  RR7      R7      pVP                  V4       V P                  VP                  4       V P                  V4      4       R# )u2   Subject: one two  three  four

test body
rJ   u   one two  three  fourzBSubject: =?utf-8?b?b25lwoUgdHdv4oCoIHRocmVl4oCp?= four

test body
r8   rK   r	   NrL   rM   s   &     r   test_flatten_unicode_linesep*TestGenerator.test_flatten_unicode_linesep+  s    SmmDHHV,-Y)MNZLLNMM!			#txx'9:LLNMM!KK$5$5E$5$JMK			#txx'9:r   c           
         ! R R\         4      pR F  pV P                  VR7      ;_uu_ 4        \        RV P                  R7      pVR V! V4      VR&   V P	                  \
        P                  P                  4      ;_uu_ 4        VP                  4        RRR4       RRR4       K  	  R#   + '       g   i     L; i  + '       g   i     K  ; i)	z=gh-121650: by default the generator prevents header injectionc                   *   a  ] tR tRt o RtR tRtV tR# )BTestGenerator.test_verify_generated_headers.<locals>.LiteralHeaderi=  Headerc                    V # rt   rs   )r   kwargss   &,r   foldGTestGenerator.test_verify_generated_headers.<locals>.LiteralHeader.fold?  s    r   rs   N)ru   rv   rw   rx   namer   r{   r|   r}   s   @r   LiteralHeaderr   =  s     D r   r   )textzHeader: Value

Bodyr	   r   N)zValue
Bad Injection
	NoNewLine)	strrZ   r   r
   assertRaisesemailerrorsHeaderWriteError	as_string)r   r   r   messages   &   r   test_verify_generated_headers+TestGenerator.test_verify_generated_headers;  s    	C 	

D 4((-/;;
 H%$1$$7!&&u||'D'DEE%%' F )(	
 FE )((s$   AC B-C -B=8C  Crs   N)ru   rv   rw   rx   staticmethodr   r   r   r   ioStringIOr   r   r   r   r   r{   r|   r   s   @r   r   r   $  s2     ./GHkkG
C; ( (r   r   c                      a  ] tR tRt o ]! ]4      t]t]	P                  tR tR tR tR tR tR tR tR	 tR
 tRtV tR# )TestBytesGeneratoriS  c                $    VP                  R 4      # )ascii)encode)r   xs   &&r   <lambda>TestBytesGenerator.<lambda>X  s    !((7+r   c                    R pRP                  R4      p\        4       pWR&   \        P                  ! 4       p\	        V4      pVP                  V4       V P                  VP                  4       V4       R# )ux   Уведомление о принятии в работу обращения для подключения услугиzSubject: =?utf-8?b?0KPQstC10LTQvtC80LvQtdC90LjQtSDQviDQv9GA0LjQvdGP0YLQuNC4?=
 =?utf-8?b?INCyINGA0LDQsdC+0YLRgyDQvtCx0YDQsNGJ0LXQvdC40Y8g0LTQu9GPINC/0L4=?=
 =?utf-8?b?0LTQutC70Y7Rh9C10L3QuNGPINGD0YHQu9GD0LPQuA==?=

r   rJ   Nr   r   r   BytesIOr   r   r   r    r?   s   &     r   =test_defaults_handle_spaces_between_encoded_words_when_foldedPTestBytesGenerator.test_defaults_handle_spaces_between_encoded_words_when_foldedZ  sf    9TU[U[\cUd 	 nIJJL1			#x0r   c                    R pRP                  R4      p\        4       pWR&   \        P                  ! 4       p\	        V4      pVP                  V4       V P                  VP                  4       V4       R# )u   A very long long long long long long long long long long long long long long long long long long long long long long long súmmäryzSubject: A very long long long long long long long long long long long long
 long long long long long long long long long long long =?utf-8?q?s=C3=BAmm?=
 =?utf-8?q?=C3=A4ry?=

r   rJ   Nr   r?   s   &     r   Btest_defaults_handle_spaces_when_encoded_words_is_folded_in_middleUTestBytesGenerator.test_defaults_handle_spaces_when_encoded_words_is_folded_in_middleg  sc    U017 	 nIJJL1			#x0r   c                    R pRp\        4       pWR&   \        P                  ! 4       p\        V4      pVP	                  V4       V P                  VP                  4       V4       R# )u    Уведомлениеs8   Subject:  =?utf-8?b?0KPQstC10LTQvtC80LvQtdC90LjQtQ==?=

rJ   Nr   r   r   r   r   r   r    r?   s   &     r   /test_defaults_handle_spaces_at_start_of_subjectBTestBytesGenerator.test_defaults_handle_spaces_at_start_of_subjectt  sP    *PnIJJL1			#x0r   c                    R pRp\        4       pWR&   \        P                  ! 4       p\        V4      pVP	                  V4       V P                  VP                  4       V4       R# )u0    ф ффффффффффффффффффф ф фsf   Subject:  =?utf-8?b?0YQg0YTRhNGE0YTRhNGE0YTRhNGE0YTRhNGE0YTRhNGE0YTRhNGE0YQ=?=
 =?utf-8?b?INGEINGE?=

rJ   Nr   r?   s   &     r   9test_defaults_handle_spaces_at_start_of_continuation_lineLTestBytesGenerator.test_defaults_handle_spaces_at_start_of_continuation_line~  sT    C1 nIJJL1			#x0r   c                8   R P                  R4      pRP                  R4      p\        V4      p\        P                  ! 4       p\	        W@P
                  P                  RR7      R7      pVP                  V4       V P                  VP                  4       V4       R# )u5   Subject: Maintenant je vous présente mon collègue

utf-8zPSubject: Maintenant je vous =?unknown-8bit?q?pr=C3=A9sente_mon_coll=C3=A8gue?=

r   7bit)cte_typer	   N)
r   r   r   r   r   r
   r+   r   r   r    r?   s   &     r   'test_cte_type_7bit_handles_unknown_8bit:TestBytesGenerator.test_cte_type_7bit_handles_unknown_8bit  sz    !"(&/ 	<=CVG_ 	 (JJL1[[%6%6%6%GH			#x0r   c                   \         P                  ! R 4      P                  R4      p\        V4      p\         P                  ! R4      P                  R4      p\        P
                  ! 4       p\        W@P                  P                  RRR7      R7      pVP                  V4       V P                  VP                  4       V4       R# )	u/              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?
            latin1a@              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?
            r   r   rE   )r   rF   r	   N)rU   rV   r   r   r   r   r   r
   r+   r   r   r    rM   s   &     r   &test_cte_type_7bit_transforms_8bit_cte9TestBytesGenerator.test_cte_type_7bit_transforms_8bit_cte  s     	" 	 ! 	 !(OO 	% 	  	 JJL1[[%6%6?C &7 &E F			#x0r   c                   \        4       pR VR&   RVR&   RVR&   VP                  R4       \        P                  ! R4      P	                  R4      P                  R	R
4      p\        P                  ! 4       p\        V\        P                  R7      pVP                  V4       V P                  VP                  4       V4       R# )u   Páolo <főo@bar.com>FromDinsdaleTou   Nudge nudge, wink, wink ὠ9rJ   u/   oh là là, know what I mean, know what I mean?u<              From: Páolo <főo@bar.com>
            To: Dinsdale
            Subject: Nudge nudge, wink, wink ὠ9
            Content-Type: text/plain; charset="utf-8"
            Content-Transfer-Encoding: 8bit
            MIME-Version: 1.0

            oh là là, know what I mean, know what I mean?
            r      
   
r	   N)r   set_contentrU   rV   r   rY   r   r   r   r
   SMTPUTF8r   r   r    rf   s   &    r   test_smtputf8_policy'TestBytesGenerator.test_smtputf8_policy  s    n-FD	:IIJ?? 	$ 	 !8 	 JJL1V__5			#x0r   c                   \        4       p\        R RR7      VR&   \        RRR7      VR&   RVR&   VP                  R	4       \        P                  ! R
4      P                  4       P                  RR4      p\        P                  ! 4       p\        V\        P                  R7      pVP                  V4       V P                  VP                  4       V4       R# )zfoo@bar.comu   Páolo)	addr_specdisplay_namer   zbar@foo.comr   r   zNudge nudge, wink, winkrJ   z+oh boy, know what I mean, know what I mean?aP              From: =?utf-8?q?P=C3=A1olo?= <foo@bar.com>
            To: Dinsdale <bar@foo.com>
            Subject: Nudge nudge, wink, wink
            Content-Type: text/plain; charset="utf-8"
            Content-Transfer-Encoding: 7bit
            MIME-Version: 1.0

            oh boy, know what I mean, know what I mean?
            r   r   r	   N)r   r   r   rU   rV   r   rY   r   r   r   r
   r>   r   r   r    rf   s   &    r   test_smtp_policy#TestBytesGenerator.test_smtp_policy  s    nHMFm*MD	2IEF?? 	$ 	 ''%1 	 JJL1V[[1			#x0r   rs   N)ru   rv   rw   rx   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r{   r|   r   s   @r   r   r   S  sP     -.GHjjG
+C111
1	1181*1 1r   r   __main__)r   rU   unittestr   r   r   email.messager   email.generatorr   r   email.headerregistryr   r
   email.errorstest.test_emailr   r   r   r   r   ru   mainrs   r   r   <module>r      sz    	   9 & 5 (   7 S; S; S;l,(%} ,(^F1*M F1R zMMO r   