From 19b5218056b02ed8454cdc095560856bdf48b8b9 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Sun, 17 Jan 2016 20:54:52 +0100 Subject: [PATCH] Add some more checks against evil URLs. --- plomlombot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plomlombot.py b/plomlombot.py index 2d2d885..7fa9194 100644 --- a/plomlombot.py +++ b/plomlombot.py @@ -12,7 +12,7 @@ servername = "" timeout = 240 username = "plomlombot" nickname = username -channel = "#zrolaps" +channel = "#zrolaps-test" class IO: @@ -104,10 +104,10 @@ while 1: url = matches[i] webpage = urllib.request.urlopen(url) content_type = webpage.info().get_content_type() - if not content_type in ('text/html', 'text/xml', + charset = webpage.info().get_content_charset() + if not charset or not content_type in ('text/html', 'text/xml', 'application/xhtml+xml'): continue - charset = webpage.info().get_content_charset() content = webpage.read().decode(charset) title = str(content).split('')[1].split('')[0] title = html.unescape(title) -- 2.30.2