|
From: Greg W. <gw...@py...> - 2002-10-29 19:39:59
|
While I'm in the mood, here's another patch for syncmail. This one
fixes bug #592836, which complains about syncmail generating "From:"
headers like
From: "" <us...@so...>
-- apparently some mail clients don't like that. And besides, it's
ugly. This patch fixes syncmail to only quote names when they actually
need to be quoted, ie. when they contain RFC 822 "special" characters.
This patch is relative to the "reply-to" patch I just posted.
--- syncmail.reply-to 2002-10-29 14:26:44.000000000 -0500
+++ syncmail 2002-10-29 14:36:43.000000000 -0500
@@ -219,6 +219,16 @@
+rfc822_specials_re = re.compile(r'[\(\)\<\>\@\,\;\:\\\"\.\[\]]')
+
+def quotename(name):
+ if name and rfc822_specials_re.search(name):
+ return '"%s"' % name.replace('"', '\\"')
+ else:
+ return name
+
+
+
def blast_mail(subject, people, filestodiff, contextlines, fromhost, replyto):
# cannot wait for child process or that will cause parent to retain cvs
# lock for too long. Urg!
@@ -236,7 +246,10 @@
s = StringIO()
sys.stdout = s
try:
- print 'From: "%s" <%s>' % (name, address)
+ if name:
+ print 'From: %s <%s>' % (quotename(name), address)
+ else:
+ print 'From: %s' % address
print 'To: %s' % string.join(people, COMMASPACE)
print 'Subject: %s' % subject
if replyto:
--
Greg Ward <gw...@py...> http://www.gerg.ca/
Eschew obfuscation!
|