bugdown: Assume http:// for links without a protocol

It's unlikely that users want relative links within humbughq.com.

Fixes #447.

(imported from commit d43a5758e6df448b07f56dc2de28078adaab8aeb)
This commit is contained in:
Keegan McAllister 2012-12-04 14:04:34 -05:00
parent d8b6cfdc11
commit 3829c8fd7f

View File

@ -65,6 +65,12 @@ class LinkPattern(markdown.inlinepatterns.Pattern):
# Bad url - so bad it couldn't be parsed.
return ''
# Humbug modification: If scheme is not specified, assume http://
# It's unlikely that users want relative links within humbughq.com.
# We re-enter sanitize_url because netloc etc. need to be re-parsed.
if not scheme:
return self.sanitize_url('http://' + url)
locless_schemes = ['', 'mailto', 'news']
if netloc == '' and scheme not in locless_schemes:
# This fails regardless of anything else.