mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	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:
		@@ -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.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user