From 3df6b983a3c39cca7a6f1a5ff0cb4658d6fdc295 Mon Sep 17 00:00:00 2001 From: Lindsey Smith Date: Tue, 21 Dec 2010 12:00:00 +0000 Subject: [PATCH] Bump to version 2.70. --- CHANGELOG | 4 ++++ rss2email.py | 38 +++++++++++++++++++++++++++----------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 208fd56..fe78dbd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +v2.70 (2010-12-21) +* Improved handling of given feed email addresses to prevent mail servers rejecting poorly formed Froms +* Added X-RSS-TAGS header that lists any tags provided by an entry, which will be helpful in filtering incoming messages + v2.69 (2010-11-12) * Added support for connecting to SMTP server via SSL, see SMTP_SSL option * Improved backwards compatibility by fixing issue with listing feeds when run with older Python versions diff --git a/rss2email.py b/rss2email.py index c752635..40b4b4d 100755 --- a/rss2email.py +++ b/rss2email.py @@ -15,7 +15,7 @@ Usage: opmlexport opmlimport filename """ -__version__ = "2.69" +__version__ = "2.70" __author__ = "Lindsey Smith (lindsey@allthingsrss.com)" __copyright__ = "(C) 2004 Aaron Swartz. GNU GPL 2 or 3." ___contributors__ = ["Dean Jackson", "Brian Lalor", "Joey Hess", @@ -432,34 +432,38 @@ def getName(r, entry): return name +def validateEmail(email, planb): + """Do a basic quality check on email address, but return planb if email doesn't appear to be well-formed""" + email_parts = email.split('@') + if len(email_parts) != 2: + return planb + return email + def getEmail(r, entry): - """Get the best email_address.""" + """Get the best email_address. If the best guess isn't well-formed (something@somthing.com), use DEFAULT_FROM instead""" feed = r.feed if FORCE_FROM: return DEFAULT_FROM if r.url in OVERRIDE_EMAIL.keys(): - return OVERRIDE_EMAIL[r.url] + return validateEmail(OVERRIDE_EMAIL[r.url], DEFAULT_FROM) if 'email' in entry.get('author_detail', []): - return entry.author_detail.email + return validateEmail(entry.author_detail.email, DEFAULT_FROM) if 'email' in feed.get('author_detail', []): - return feed.author_detail.email + return validateEmail(feed.author_detail.email, DEFAULT_FROM) - #TODO: contributors - if USE_PUBLISHER_EMAIL: if 'email' in feed.get('publisher_detail', []): - return feed.publisher_detail.email + return validateEmail(feed.publisher_detail.email, DEFAULT_FROM) if feed.get("errorreportsto", ''): - return feed.errorreportsto + return validateEmail(feed.errorreportsto, DEFAULT_FROM) if r.url in DEFAULT_EMAIL.keys(): return DEFAULT_EMAIL[r.url] - return DEFAULT_FROM ### Simple Database of Feeds ### @@ -676,7 +680,19 @@ def run(num=None): subjecthdr = title datehdr = time.strftime("%a, %d %b %Y %H:%M:%S -0000", datetime) useragenthdr = "rss2email" - extraheaders = {'Date': datehdr, 'User-Agent': useragenthdr, 'X-RSS-Feed': f.url, 'X-RSS-ID': id, 'X-RSS-URL': link} + + # Add post tags, if available + tagline = "" + if 'tags' in entry: + tags = entry.get('tags') + taglist = [] + if tags: + for tag in tags: + taglist.append(tag['term']) + if taglist: + tagline = ",".join(taglist) + + extraheaders = {'Date': datehdr, 'User-Agent': useragenthdr, 'X-RSS-Feed': f.url, 'X-RSS-ID': id, 'X-RSS-URL': link, 'X-RSS-TAGS' : tagline} if BONUS_HEADER != '': for hdr in BONUS_HEADER.strip().splitlines(): pos = hdr.strip().find(':') -- 2.26.2