From 42fa878f929c6ee39c8068d186de1ae7f4630638 Mon Sep 17 00:00:00 2001 From: Lindsey Smith Date: Mon, 14 Mar 2011 09:18:42 -0700 Subject: [PATCH] Improved basic email validation --- rss2email.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rss2email.py b/rss2email.py index 0dc2d04..3299cd5 100644 --- a/rss2email.py +++ b/rss2email.py @@ -15,7 +15,7 @@ Usage: opmlexport opmlimport filename """ -__version__ = "2.70" +__version__ = "2.72" __author__ = "Lindsey Smith (lindsey@allthingsrss.com)" __copyright__ = "(C) 2004 Aaron Swartz. GNU GPL 2 or 3." ___contributors__ = ["Dean Jackson", "Brian Lalor", "Joey Hess", @@ -295,6 +295,7 @@ for e in ['error', 'gaierror']: import feedparser feedparser.USER_AGENT = "rss2email/"+__version__+ " +http://www.allthingsrss.com/rss2email/" +feedparser.SANITIZE_HTML = 0 import html2text as h2t @@ -406,7 +407,8 @@ def getID(entry): if 'title' in entry: return hash(unu(entry.title)).hexdigest() def getName(r, entry): - """Get the best name.""" + """Get the best name. + NEEDS UNIT TESTS""" if NO_FRIENDLY_NAME: return '' @@ -435,12 +437,13 @@ def getName(r, entry): 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: + if (len(email_parts) != 2) or not email_parts[0] or not email_parts[1]: return planb return email def getEmail(r, entry): - """Get the best email_address. If the best guess isn't well-formed (something@somthing.com), use DEFAULT_FROM instead""" + """Get the best email_address. If the best guess isn't well-formed (something@somthing.com), use DEFAULT_FROM instead. + NEEDS UNIT TESTS""" feed = r.feed -- 2.26.2