Bump to version 2.70. v2.70
authorLindsey Smith <lindsey@allthingsrss.com>
Tue, 21 Dec 2010 12:00:00 +0000 (12:00 +0000)
committerW. Trevor King <wking@tremily.us>
Thu, 4 Oct 2012 11:05:46 +0000 (07:05 -0400)
CHANGELOG
rss2email.py

index 208fd567d8f45420c9b49ac87bec29bc50218cc8..fe78dbd21a50c9ae486f0ddce5af0e82b5679749 100644 (file)
--- 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
index c752635be32bfa17e2fd185b7d071ce0cf2dd6e4..40b4b4d5cfcc5b5d3c9241774dd38bcdd086b91a 100755 (executable)
@@ -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(':')