[title] Restrict accepted URLs (only https?://)

master
sfan5 2016-03-26 11:44:04 +01:00
parent 113c7f86e1
commit 03fd6b2017
1 changed files with 3 additions and 1 deletions

View File

@ -14,10 +14,12 @@ def title(phenny, input):
uri = input.group(2) uri = input.group(2)
if uri: if uri:
uri = uri.strip() uri = uri.strip()
if not uri.startswith("http://") and not uri.startswith("https://"):
return phenny.say("That's not a valid URL")
elif hasattr(phenny.bot, 'last_seen_uri'): elif hasattr(phenny.bot, 'last_seen_uri'):
uri = phenny.bot.last_seen_uri uri = phenny.bot.last_seen_uri
else: else:
return phenny.reply("Give me an URI..") return phenny.reply("Give me a link.")
data, sc = web.get(uri, 16384) data, sc = web.get(uri, 16384)
if sc != 200: if sc != 200:
return phenny.say("HTTP error %d" % sc) return phenny.say("HTTP error %d" % sc)