From: Etienne Millon Date: Fri, 25 May 2012 16:04:08 +0000 (+0200) Subject: Fix email header injection X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=883d0bf7ac174b061d7aaad96dfe1a949fbb0a37;p=rss2email.git Fix email header injection Bug: http://bugs.python.org/issue5871 Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=526064 --- diff --git a/rss2email.py b/rss2email.py index 69998db..a6c3cbe 100755 --- a/rss2email.py +++ b/rss2email.py @@ -111,9 +111,16 @@ PROXY="" CHARSET_LIST='US-ASCII', 'ISO-8859-1', 'UTF-8', 'BIG5', 'ISO-2022-JP' from email.MIMEText import MIMEText -from email.Header import Header +from email.Header import Header as _Header from email.Utils import parseaddr, formataddr - + +class Header(_Header): + # Work-around for + def append(self, s=None, *args, **kwargs): + if s is not None: + s = s.replace('\n', ' ').replace('\r', ' ') + _Header.append(self, s, *args, **kwargs) + # Note: You can also override the send function. def send(sender, recipient, subject, body, contenttype, extraheaders=None, smtpserver=None):