From: Christian Heller Date: Sun, 17 Jan 2016 19:54:52 +0000 (+0100) Subject: Add some more checks against evil URLs. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/static/template?a=commitdiff_plain;h=19b5218056b02ed8454cdc095560856bdf48b8b9;p=plomlombot-irc.git Add some more checks against evil URLs. --- 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)