commit 7274f9076d9a7d9e65417808677a98277f3fd10e
parent dfe52be165706983713f2b886988bfdc628f769a
Author: Christoph Lohmann <20h@r-36.net>
Date: Wed, 24 Jul 2019 08:03:50 +0200
On empty headers, do not barf when normalize.
Diffstat:
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/zeitungsschau/feedemail.py b/zeitungsschau/feedemail.py
@@ -13,6 +13,7 @@ from email.header import Header
import time
import subprocess
import lxml.html
+import lxml.etree
import urllib.parse
import html2text
@@ -20,10 +21,13 @@ import html2text
def normalizeheader(hstr):
if len(hstr) == 0:
return ""
+ try:
+ return lxml.html.fromstring(hstr).text_content().\
+ replace(u"\xa0", "").\
+ replace("\n", " ").strip()
+ except lxml.etree.ParserError:
+ return ""
- return lxml.html.fromstring(hstr).text_content().\
- replace(u"\xa0", "").\
- replace("\n", " ").strip()
class LocalSendmail(object):
cmd="/usr/sbin/sendmail -f \"%s\" \"%s\""