From 9dc53d3eab35e561f060a4b32ad2050736977dc6 Mon Sep 17 00:00:00 2001 From: richard Date: Mon, 23 Feb 2004 05:29:06 +0000 Subject: [PATCH] Eudora can't handle utf-8 headers. We love Eudora. (sf bug 900046) git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@2103 57a73879-2fb5-44c3-a270-3262357dd7e2 --- CHANGES.txt | 1 + doc/customizing.txt | 15 ++++++++++++++- roundup/mailer.py | 5 +++-- roundup/rfc2822.py | 3 +-- roundup/roundupdb.py | 11 +++++++---- templates/classic/config.py | 10 +++++++++- templates/minimal/config.py | 9 ++++++++- 7 files changed, 43 insertions(+), 11 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 36aa268..aebccff 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -74,6 +74,7 @@ Cleanup: 2004-??-?? 0.6.6 Fixed: - don't insert spaces into designators, it just confuses users (sf bug 898087) +- Eudora can't handle utf-8 headers. We love Eudora. (sf bug 900046) 2004-02-16 0.6.5 diff --git a/doc/customizing.txt b/doc/customizing.txt index 4e6dc27..5607cdd 100644 --- a/doc/customizing.txt +++ b/doc/customizing.txt @@ -2,7 +2,7 @@ Customising Roundup =================== -:Version: $Revision: 1.115 $ +:Version: $Revision: 1.116 $ .. This document borrows from the ZopeBook section on ZPT. The original is at: http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx @@ -187,6 +187,12 @@ The configuration variables available are: wish to make them xhtml, then you'll need to change this var to 'xhtml' too so all auto-generated HTML is compliant. +**EMAIL_CHARSET** - ``utf-8`` (or ``iso-8859-1`` for Eudora users) + Character set to encode email headers with. We use utf-8 by default, as + it's the most flexible. Some mail readers (eg. Eudora) can't cope with + that, so you might need to specify a more limited character set (eg. + 'iso-8859-1'. + The default config.py is given below - as you can see, the MAIL_DOMAIN must be edited before any interaction with the tracker is attempted.:: @@ -267,6 +273,13 @@ tracker is attempted.:: # too so all auto-generated HTML is compliant. HTML_VERSION = 'html4' # either 'html4' or 'xhtml' + # Character set to encode email headers with. We use utf-8 by default, as + # it's the most flexible. Some mail readers (eg. Eudora) can't cope with + # that, so you might need to specify a more limited character set (eg. + # 'iso-8859-1'. + EMAIL_CHARSET = 'utf-8' + #EMAIL_CHARSET = 'iso-8859-1' # use this instead for Eudora users + # # SECURITY DEFINITIONS # diff --git a/roundup/mailer.py b/roundup/mailer.py index ec5951e..ea51fe5 100644 --- a/roundup/mailer.py +++ b/roundup/mailer.py @@ -1,7 +1,7 @@ """Sending Roundup-specific mail over SMTP. """ __docformat__ = 'restructuredtext' -# $Id: mailer.py,v 1.5 2004-02-11 23:55:08 richard Exp $ +# $Id: mailer.py,v 1.6 2004-02-23 05:29:05 richard Exp $ import time, quopri, os, socket, smtplib, re @@ -29,7 +29,8 @@ class Mailer: self.config.ADMIN_EMAIL)) message = StringIO() writer = MimeWriter(message) - writer.addheader('Subject', encode_header(subject)) + writer.addheader('Subject', encode_header(subject, + self.config.EMAIL_CHARSET)) writer.addheader('To', ', '.join(to)) writer.addheader('From', author) writer.addheader('Date', time.strftime("%a, %d %b %Y %H:%M:%S +0000", diff --git a/roundup/rfc2822.py b/roundup/rfc2822.py index a54d34f..8fba2ad 100644 --- a/roundup/rfc2822.py +++ b/roundup/rfc2822.py @@ -119,7 +119,7 @@ def decode_header(hdr): outs += unicode(section[0], charset or 'iso-8859-1', 'replace') return outs.encode('utf-8') -def encode_header(header): +def encode_header(header, charset='utf-8'): """ Will encode in quoted-printable encoding only if header contains non latin characters """ @@ -132,7 +132,6 @@ def encode_header(header): if hqre.match(header): return header - charset = 'utf-8' quoted = '' #max_encoded = 76 - len(charset) - 7 for c in header: diff --git a/roundup/roundupdb.py b/roundup/roundupdb.py index 761f1ae..6160847 100644 --- a/roundup/roundupdb.py +++ b/roundup/roundupdb.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: roundupdb.py,v 1.97 2004-02-11 23:55:08 richard Exp $ +# $Id: roundupdb.py,v 1.98 2004-02-23 05:29:05 richard Exp $ """Extending hyperdb with types specific to issue-tracking. """ @@ -268,14 +268,17 @@ class IssueClass: if from_tag: from_tag = ' ' + from_tag - subject = '[%s%s] %s' % (cn, nodeid, encode_header(title)) - author = straddr((encode_header(authname) + from_tag, from_address)) + subject = '[%s%s] %s' % (cn, nodeid, encode_header(title, + self.db.config.EMAIL_CHARSET)) + author = straddr((encode_header(authname, self.db.config.EMAIL_CHARSET) + + from_tag, from_address)) # create the message mailer = Mailer(self.db.config) message, writer = mailer.get_standard_message(sendto, subject, author) - tracker_name = encode_header(self.db.config.TRACKER_NAME) + tracker_name = encode_header(self.db.config.TRACKER_NAME, + self.db.config.EMAIL_CHARSET) writer.addheader('Reply-To', straddr((tracker_name, from_address))) if messageid: writer.addheader('Message-Id', messageid) diff --git a/templates/classic/config.py b/templates/classic/config.py index e6f6133..f536784 100644 --- a/templates/classic/config.py +++ b/templates/classic/config.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: config.py,v 1.4 2003-12-06 00:00:54 richard Exp $ +# $Id: config.py,v 1.5 2004-02-23 05:29:05 richard Exp $ import os @@ -111,6 +111,14 @@ MAIL_DEFAULT_CLASS = 'issue' # use "issue" class by default # too so all auto-generated HTML is compliant. HTML_VERSION = 'html4' # either 'html4' or 'xhtml' +# Character set to encode email headers with. We use utf-8 by default, as +# it's the most flexible. Some mail readers (eg. Eudora) can't cope with +# that, so you might need to specify a more limited character set (eg. +# 'iso-8859-1'. +EMAIL_CHARSET = 'utf-8' +#EMAIL_CHARSET = 'iso-8859-1' # use this instead for Eudora users + + # # SECURITY DEFINITIONS # diff --git a/templates/minimal/config.py b/templates/minimal/config.py index a3ceeb6..cf82f22 100644 --- a/templates/minimal/config.py +++ b/templates/minimal/config.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: config.py,v 1.3 2003-12-06 00:00:54 richard Exp $ +# $Id: config.py,v 1.4 2004-02-23 05:29:06 richard Exp $ import os @@ -115,4 +115,11 @@ MAIL_DEFAULT_CLASS = 'issue' # use "issue" class by default # too so all auto-generated HTML is compliant. HTML_VERSION = 'html4' # either 'html4' or 'xhtml' +# Character set to encode email headers with. We use utf-8 by default, as +# it's the most flexible. Some mail readers (eg. Eudora) can't cope with +# that, so you might need to specify a more limited character set (eg. +# 'iso-8859-1'. +EMAIL_CHARSET = 'utf-8' +#EMAIL_CHARSET = 'iso-8859-1' # use this instead for Eudora users + # vim: set filetype=python ts=4 sw=4 et si -- 2.30.2