From a62784e2a100a390ad12721a27978accd036f0ea Mon Sep 17 00:00:00 2001 From: kedder Date: Tue, 6 May 2003 21:49:20 +0000 Subject: [PATCH] more pedantic rfc2822 header qp encoding git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1693 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/rfc2822.py | 3 ++- test/test_mailgw.py | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/roundup/rfc2822.py b/roundup/rfc2822.py index d601ee1..0faa833 100644 --- a/roundup/rfc2822.py +++ b/roundup/rfc2822.py @@ -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 @@ ecre = re.compile(r''' \?= # 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. diff --git a/test/test_mailgw.py b/test/test_mailgw.py index d524b78..355de47 100644 --- a/test/test_mailgw.py +++ b/test/test_mailgw.py @@ -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 # 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 @@ This is a followup 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), ] -- 2.30.2