From 3829c8fd7f52a942e1cda1268694f7eaefa89408 Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Tue, 4 Dec 2012 14:04:34 -0500 Subject: [PATCH] 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) --- zephyr/lib/bugdown/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/zephyr/lib/bugdown/__init__.py b/zephyr/lib/bugdown/__init__.py index 01c63a1ca4..a21561512f 100644 --- a/zephyr/lib/bugdown/__init__.py +++ b/zephyr/lib/bugdown/__init__.py @@ -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.