From 760da8ef61093e49dad06b080c05e35082aef4a9 Mon Sep 17 00:00:00 2001 From: nemunaire Date: Tue, 15 Sep 2015 20:15:35 +0200 Subject: [PATCH] tools.web: don't try to striphtml content that is not str or buffer --- nemubot/tools/web.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nemubot/tools/web.py b/nemubot/tools/web.py index 0cf25fa..8955d5d 100644 --- a/nemubot/tools/web.py +++ b/nemubot/tools/web.py @@ -208,6 +208,9 @@ def striphtml(data): data -- the string to strip """ + if data is None or (not isinstance(data, str) and not isinstance(data, buffer)): + return data + import re p = re.compile(r'<.*?>') r, _ = re.subn(r' +', ' ', htmlentitydecode(p.sub('', data)