diff options
Diffstat (limited to 'Mailman/Handlers/ToDigest.py')
-rw-r--r-- | Mailman/Handlers/ToDigest.py | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/Mailman/Handlers/ToDigest.py b/Mailman/Handlers/ToDigest.py index edbf40dc..046cbaba 100644 --- a/Mailman/Handlers/ToDigest.py +++ b/Mailman/Handlers/ToDigest.py @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2011 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2017 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -68,6 +68,17 @@ except NameError: +def to_cset_out(text, lcset): + # Convert text from unicode or lcset to output cset. + ocset = Charset(lcset).get_output_charset() or lcset + if isinstance(text, unicode): + return text.encode(ocset, errors='replace') + else: + return text.decode(lcset, errors='replace').encode(ocset, + errors='replace') + + + def process(mlist, msg, msgdata): # Short circuit non-digestable lists. if not mlist.digestable or msgdata.get('isdigest'): @@ -86,7 +97,8 @@ def process(mlist, msg, msgdata): # whether the size threshold has been reached. mboxfp.flush() size = os.path.getsize(mboxfile) - if size / 1024.0 >= mlist.digest_size_threshhold: + if (mlist.digest_size_threshhold > 0 and + size / 1024.0 >= mlist.digest_size_threshhold): # This is a bit of a kludge to get the mbox file moved to the digest # queue directory. try: @@ -203,8 +215,8 @@ def send_i18n_digests(mlist, mboxfp): # RFC 1153 print >> plainmsg, mastheadtxt print >> plainmsg - # Now add the optional digest header - if mlist.digest_header: + # Now add the optional digest header but only if more than whitespace. + if re.sub('\s', '', mlist.digest_header): headertxt = decorate(mlist, mlist.digest_header, _('digest header')) # MIME header = MIMEText(headertxt, _charset=lcset) @@ -298,7 +310,7 @@ def send_i18n_digests(mlist, mboxfp): if msgcount == 0: # Why did we even get here? return - toctext = toc.getvalue() + toctext = to_cset_out(toc.getvalue(), lcset) # MIME tocpart = MIMEText(toctext, _charset=lcset) tocpart['Content-Description']= _("Today's Topics (%(msgcount)d messages)") @@ -353,8 +365,8 @@ def send_i18n_digests(mlist, mboxfp): print >> plainmsg, payload if not payload.endswith('\n'): print >> plainmsg - # Now add the footer - if mlist.digest_footer: + # Now add the footer but only if more than whitespace. + if re.sub('\s', '', mlist.digest_footer): footertxt = decorate(mlist, mlist.digest_footer, _('digest footer')) # MIME footer = MIMEText(footertxt, _charset=lcset) @@ -411,7 +423,7 @@ def send_i18n_digests(mlist, mboxfp): listname=mlist.internal_name(), isdigest=True) # RFC 1153 - rfc1153msg.set_payload(plainmsg.getvalue(), lcset) + rfc1153msg.set_payload(to_cset_out(plainmsg.getvalue(), lcset), lcset) virginq.enqueue(rfc1153msg, recips=plainrecips, listname=mlist.internal_name(), |