home · contact · privacy
Add some more checks against evil URLs.
authorChristian Heller <c.heller@plomlompom.de>
Sun, 17 Jan 2016 19:54:52 +0000 (20:54 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 17 Jan 2016 19:54:52 +0000 (20:54 +0100)
plomlombot.py

index 2d2d885d9436b13f97223a5bc3c897634a09e36b..7fa9194af8236e27fd7d547843fc1a1e3577dc8b 100644 (file)
@@ -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('<title>')[1].split('</title>')[0]
                 title = html.unescape(title)