Mercurial > p > roundup > code
changeset 1628:ea1afeb64b45
more pedantic rfc2822 header qp encoding
| author | Andrey Lebedev <kedder@users.sourceforge.net> |
|---|---|
| date | Tue, 06 May 2003 21:49:20 +0000 |
| parents | e029d625c8f1 |
| children | 27768800be5c |
| files | roundup/rfc2822.py test/test_mailgw.py |
| diffstat | 2 files changed, 11 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/roundup/rfc2822.py Wed Apr 30 01:28:37 2003 +0000 +++ b/roundup/rfc2822.py Tue May 06 21:49:20 2003 +0000 @@ -1,4 +1,5 @@ import re +from string import letters, digits from binascii import b2a_base64, a2b_base64 ecre = re.compile(r''' @@ -11,7 +12,7 @@ \?= # literal ?= ''', re.VERBOSE | re.IGNORECASE) -hqre = re.compile(r'^[-a-zA-Z0-9!*+/\[\]., ]+$') +hqre = re.compile(r'^[A-z0-9!"#$%%&\'()*+,-./:;<=>?@\[\]^_`{|}~ ]+$') def base64_decode(s, convert_eols=None): """Decode a raw base64 string.
--- a/test/test_mailgw.py Wed Apr 30 01:28:37 2003 +0000 +++ b/test/test_mailgw.py Tue May 06 21:49:20 2003 +0000 @@ -8,7 +8,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# $Id: test_mailgw.py,v 1.45 2003-04-27 02:16:47 richard Exp $ +# $Id: test_mailgw.py,v 1.46 2003-05-06 21:49:20 kedder Exp $ import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys, difflib import rfc822 @@ -22,7 +22,7 @@ # import rfc822 as email from roundup.mailgw import MailGW, Unauthorized, uidFromAddress -from roundup import init, instance +from roundup import init, instance, rfc2822 # TODO: make this output only enough equal lines for context, not all of # them @@ -952,6 +952,13 @@ i = uidFromAddress(self.db, ('', 'user@foo.com'), 1) self.assertNotEqual(uidFromAddress(self.db, ('', 'user@bar.com'), 1), i) + def testRFC2822(self): + ascii_header = "[issue243] This is a \"test\" - with 'quotation' marks" + unicode_header = '[issue244] \xd0\xb0\xd0\xbd\xd0\xb4\xd1\x80\xd0\xb5\xd0\xb9' + unicode_encoded = '=?utf-8?q?[issue244]_=D0=B0=D0=BD=D0=B4=D1=80=D0=B5=D0=B9?=' + self.assertEqual(rfc2822.encode_header(ascii_header), ascii_header) + self.assertEqual(rfc2822.encode_header(unicode_header), unicode_encoded) + def suite(): l = [unittest.makeSuite(MailgwTestCase), ]
