From 67cc85bdcd6152e7c1079ad5b095fbe5668ac306 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 14 May 2013 07:03:32 -0400 Subject: [PATCH] command: Fix opmlexport crash due to orphaned feed data When you remove a feed from your config file by hand, you might leave the dynamic 'seen' data in the JSON data file by accident. If you have such orphan data, the feed is loaded by Feeds._load_feeds() with the default configuration (since you removed the config file entry). This can lead to opmlexport errors like: Traceback (most recent call last): File "./r2e", line 5, in rss2email.main.run() File "/.../rss2email/rss2email/main.py", line 163, in run args.func(feeds=feeds, args=args) File "/.../rss2email/rss2email/command.py", line 157, in opmlexport url = _saxutils.escape(feed.url) File "/usr/lib64/python3.2/xml/sax/saxutils.py", line 34, in escape data = data.replace("&", "&") AttributeError: 'NoneType' object has no attribute 'replace' because the feeds lack the per-feed 'url' setting that had been defined in the config file. With this commit, opmlexport drops these URL-less feeds, instead of choking to death trying to format them ;). Signed-off-by: W. Trevor King --- CHANGELOG | 1 + rss2email/command.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 2f8d325..d7e6c31 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ v3.5 (unreleased) * Fix html2text configuration (ignored since 2012-10-04). + * Fix opmlexport crash due to orphaned feed data. v3.4 (2013-05-14) * Added post-processing hooks for user-specified message manipulation. diff --git a/rss2email/command.py b/rss2email/command.py index 8d8fc82..c43e4ad 100644 --- a/rss2email/command.py +++ b/rss2email/command.py @@ -154,6 +154,9 @@ def opmlexport(feeds, args): '\n' '\n') for feed in feeds: + if not feed.url: + _LOG.debug('dropping {}'.format(feed)) + continue url = _saxutils.escape(feed.url) f.write(''.format(url)) f.write( -- 2.26.2