From: W. Trevor King Date: Fri, 7 Nov 2014 06:18:13 +0000 (-0800) Subject: ssoma-mda: Unfold folding whitespace in message subjects X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5ea52ac3ec53d8edd37924743ae028b59b91a1b0;p=ssoma-mda.git ssoma-mda: Unfold folding whitespace in message subjects For the RFC specs on folding whitespace, see [1] and [2]. For the decision to preserve the original folding in Python headers, here's R. David Murray's comment from 2011-04-18 [3]: I have, by the way, come around to the view that we should never be introducing or deleting whitespace except when RFC 2047 encoding/decoding...we are still deleting it in a couple places, and I will address that by and by [1]: https://tools.ietf.org/html/rfc5322#section-2.2.3 [2]: https://tools.ietf.org/html/rfc5322#section-3.2.2 [3]: http://bugs.python.org/issue1372770#msg133974 --- diff --git a/ssoma-mda b/ssoma-mda index 10b8d3d..39bed3e 100755 --- a/ssoma-mda +++ b/ssoma-mda @@ -50,6 +50,7 @@ import email.utils as _email_utils import hashlib as _hashlib import logging as _logging import os.path as _os_path +import re as _re import sys as _sys import pygit2 as _pygit2 @@ -61,6 +62,7 @@ _LOG.setLevel(_logging.ERROR) _LOG.addHandler(_logging.StreamHandler()) _COMMIT_MESSAGE_ENCODING = 'UTF-8' +_FOLDING_WHITESPACE_REGEX = _re.compile('\s*\n\s*') class DirtyIndex(RuntimeError): @@ -258,6 +260,8 @@ def deliver(message=None, message_bytes=None, **kwargs): path = message_id_path(message_id=message_id) _LOG.info('deliver {} to {}'.format(message_id, path)) commit_message = message.get('Subject', '') + if '\n' in commit_message: + commit_message = _FOLDING_WHITESPACE_REGEX.sub(' ', commit_message) author = get_author(message=message) repository = _pygit2.Repository(_os_path.curdir) append(