From 4f6cc7ed9e24196383be02e8bbc38e02795b08ab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Thu, 1 Aug 2013 16:06:23 +0200 Subject: [PATCH 1/1] =?utf8?q?Ajout=20fonction=20utilitaire=20pour=20encod?= =?utf8?q?er=20de=20mani=C3=A8re=20s=C3=A9curis=C3=A9=20les=20en-t=C3=AAte?= =?utf8?q?=20des=20mails.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- utils.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/utils.py b/utils.py index 7c5ceb7..8f6bd3d 100755 --- a/utils.py +++ b/utils.py @@ -261,6 +261,29 @@ def encodeQuopriEmail(name, email) : qpName = encodestring(name).replace('=\n', '') return '''"=?utf-8?q?%s?=" <%s>''' % (qpName, email) +def encodeMailHeader(content) : + s = encodestring(content).replace('=\n', '') + s = s.replace('_', '=5F') + s = s.replace(' ', '_') + + lines = [] + STEP = 50 + start = 0 + stop = STEP + part = s[start:stop] + lines.append(part) + + while len(part) == STEP: + start = start + STEP + stop = stop + STEP + part = s[start:stop] + lines.append(part) + + lines = [' =?utf-8?Q?%s?=' % part for part in lines] + s = '\n'.join(lines) + s = s.strip() + return s + def _sudo(func, userid=None) : """ -- 2.20.1