Skip to content

Commit

Permalink
meetbot/url: fix SSLError
Browse files Browse the repository at this point in the history
The core.verify_ssl was not passed to url.find_title(), resulting in SSL errors on sites with invalid certs when `verify_ssl = False`

Slight refactor of @psachin's original code for backwards compatibility. Resolves sopel-irc#1113
  • Loading branch information
maxpowa committed Jul 28, 2016
1 parent dda0abc commit a047ee7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sopel/modules/meetbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def meetinglink(bot, trigger):
if not link.startswith("http"):
link = "http://" + link
try:
title = find_title(link)
title = find_title(link, verify=bot.config.core.verify_ssl)
except:
title = ''
logplain('LINK: %s [%s]' % (link, title), trigger.sender)
Expand Down
6 changes: 3 additions & 3 deletions sopel/modules/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def process_urls(bot, trigger, urls):
if matched:
continue
# Finally, actually show the URL
title = find_title(url)
title = find_title(url, verify=bot.config.core.verify_ssl)
if title:
results.append((title, get_hostname(url)))
return results
Expand All @@ -182,9 +182,9 @@ def check_callbacks(bot, trigger, url, run=True):
return matched


def find_title(url):
def find_title(url, verify=True):
"""Return the title for the given URL."""
response = requests.get(url, stream=True)
response = requests.get(url, stream=True, verify=verify)
try:
content = ''
for byte in response.iter_content(chunk_size=512, decode_unicode=True):
Expand Down

0 comments on commit a047ee7

Please sign in to comment.