1
0
mirror of http://aero2k.de/t/repos/urlbot-native.git synced 2017-09-06 15:25:38 +02:00

fix crash for https?://\..* links ('.'.encode('idna') fails)

This commit is contained in:
urlbot
2014-10-09 22:48:23 +02:00
parent 24084909a4
commit e4d23e07c0

View File

@@ -130,6 +130,19 @@ def extract_url(data):
result = re.findall("(https?://[^\s>]+)", data)
if result:
for url in result:
# urllib.request is broken:
# >>> '.'.encode('idna')
# ....
# UnicodeError: label empty or too long
# >>> '.a.'.encode('idna')
# ....
# UnicodeError: label empty or too long
# >>> 'a.a.'.encode('idna')
# b'a.a.'
if re.match(r'https?://\.', url):
logger('warn', 'bug tiggered, invalid url: %s' % url)
continue
ratelimit_touch()
if ratelimit_exceeded():
return False