home
·
contact
·
privacy
projects
/
plomlombot-irc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
189aecc
)
Add some more checks against evil URLs.
author
Christian Heller
<c.heller@plomlompom.de>
Sun, 17 Jan 2016 19:54:52 +0000
(20:54 +0100)
committer
Christian Heller
<c.heller@plomlompom.de>
Sun, 17 Jan 2016 19:54:52 +0000
(20:54 +0100)
plomlombot.py
patch
|
blob
|
history
diff --git
a/plomlombot.py
b/plomlombot.py
index 2d2d885d9436b13f97223a5bc3c897634a09e36b..7fa9194af8236e27fd7d547843fc1a1e3577dc8b 100644
(file)
--- a/
plomlombot.py
+++ b/
plomlombot.py
@@
-12,7
+12,7
@@
servername = ""
timeout = 240
username = "plomlombot"
nickname = username
timeout = 240
username = "plomlombot"
nickname = username
-channel = "#zrolaps"
+channel = "#zrolaps
-test
"
class IO:
class IO:
@@
-104,10
+104,10
@@
while 1:
url = matches[i]
webpage = urllib.request.urlopen(url)
content_type = webpage.info().get_content_type()
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
'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)
content = webpage.read().decode(charset)
title = str(content).split('<title>')[1].split('</title>')[0]
title = html.unescape(title)