File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -141,7 +141,7 @@ def encode_header(header, charset='utf-8'):
141141 if c == ' ' :
142142 quoted += '_'
143143 # These characters can be included verbatim
144- elif hqre .match (c ) and c != '_ ' :
144+ elif hqre .match (c ) and c not in '_= ' :
145145 quoted += c
146146 # Otherwise, replace with hex value like =E2
147147 else :
Original file line number Diff line number Diff line change 1+ from roundup .rfc2822 import decode_header , encode_header
2+
3+ import unittest , time
4+
5+ class RFC2822TestCase (unittest .TestCase ):
6+ def testDecode (self ):
7+ src = 'Re: [it_issue3] ' \
8+ '=?ISO-8859-1?Q?Ren=E9s_[resp=3Dg=2Cstatus=3D?= ' \
9+ '=?ISO-8859-1?Q?feedback]?='
10+ result = 'Re: [it_issue3] Ren\xc3 \xa9 s [resp=g,status=feedback]'
11+ self .assertEqual (decode_header (src ), result )
12+
13+ src = 'Re: [it_issue3]' \
14+ ' =?ISO-8859-1?Q?Ren=E9s_[resp=3Dg=2Cstatus=3D?=' \
15+ ' =?ISO-8859-1?Q?feedback]?='
16+ result = 'Re: [it_issue3] Ren\xc3 \xa9 s [resp=g,status=feedback]'
17+ self .assertEqual (decode_header (src ), result )
18+
19+ def testEncode (self ):
20+ src = 'Re: [it_issue3] Ren\xc3 \xa9 s [status=feedback]'
21+ result = '=?utf-8?q?Re:_[it=5Fissue3]_Ren=C3=A9s_[status=3Dfeedback]?='
22+ self .assertEqual (encode_header (src ), result )
23+
24+ def test_suite ():
25+ suite = unittest .TestSuite ()
26+ suite .addTest (unittest .makeSuite (RFC2822TestCase ))
27+ return suite
You can’t perform that action at this time.
0 commit comments