bugdown: Don't generate garbage on invalid links.

LinkPattern returned a string which contained a placeholder if the URL was
considered invalid. AtomicLinkPattern wrapped this in an AtomicString,
where the placeholder doesn't get removed properly.

m.group(0) is always incorrect because python-markdown modifies your regex
to include more than you specified (this is why part of the message got
duplicated).

(imported from commit 576bdf09c2b677cf4bc56484c363eb05f2110158)
This commit is contained in:
Kevin Mehall
2013-09-18 16:04:18 -04:00
parent 63cff6eb71
commit 8c7f1ecffa
2 changed files with 6 additions and 7 deletions

View File

@@ -2596,13 +2596,14 @@ int x = 3
('javascript://foo.com', "<p>javascript://foo.com</p>", ''),
('foobarscript://foo.com', "<p>foobarscript://foo.com</p>", ''),
('about:blank.com', "<p>about:%s</p>", 'blank.com'),
('[foo](javascript:foo.com)', "<p>[foo](javascript:foo.com)</p>", ''),
('[foo](javascript:foo.com)', "<p>[foo](javascript:%s)</p>", 'foo.com'),
('[foo](javascript://foo.com)', "<p>[foo](javascript://foo.com)</p>", ''),
# Other weird URL schemes are also blocked
('aim:addbuddy?screenname=foo', "<p>aim:addbuddy?screenname=foo</p>", ''),
('itms://itunes.com/apps/appname', "<p>itms://itunes.com/apps/appname</p>", ''),
('[foo](itms://itunes.com/apps/appname)', "<p>[foo](itms://itunes.com/apps/appname)</p>", ''),
('1 [](foo://) 3 [](foo://) 5', "<p>1 [](foo://) 3 [](foo://) 5</p>", ''),
# Make sure we HTML-escape the invalid URL on output.
# ' and " aren't escaped here, because we aren't in attribute context.