mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	bugdown: Fix handling of twitter-format links that aren't actually tweets.
(imported from commit 60512147d8d303ff07cf1e86306fd14b1490e708)
This commit is contained in:
		@@ -302,10 +302,14 @@ class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor):
 | 
			
		||||
                if rendered_tweet:
 | 
			
		||||
                    # Only render at most one tweet per message
 | 
			
		||||
                    continue
 | 
			
		||||
                twitter_data = self.twitter_link(url)
 | 
			
		||||
                if twitter_data is None:
 | 
			
		||||
                    # This link is not actually a tweet known to twitter
 | 
			
		||||
                    continue
 | 
			
		||||
                rendered_tweet = True
 | 
			
		||||
                div = markdown.util.etree.SubElement(root, "div")
 | 
			
		||||
                div.set("class", "inline-preview-twitter")
 | 
			
		||||
                div.insert(0, self.twitter_link(url))
 | 
			
		||||
                div.insert(0, twitter_data)
 | 
			
		||||
                continue
 | 
			
		||||
            if embedly_client.is_supported(url):
 | 
			
		||||
                embedly_urls.append(url)
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,8 @@
 | 
			
		||||
import simplejson
 | 
			
		||||
 | 
			
		||||
def twitter(tweet_id):
 | 
			
		||||
    if tweet_id not in ["112652479837110273", "287977969287315456", "287977969287315457"]:
 | 
			
		||||
        return None
 | 
			
		||||
    return simplejson.loads("""{
 | 
			
		||||
  "coordinates": null,
 | 
			
		||||
  "created_at": "Sat Sep 10 22:23:38 +0000 2011",
 | 
			
		||||
 
 | 
			
		||||
@@ -2239,6 +2239,11 @@ xxxxxxx</strong></p>\n<p>xxxxxxx xxxxx xxxx xxxxx:<br>\n<code>xxxxxx</code>: xxx
 | 
			
		||||
        converted = convert(msg)
 | 
			
		||||
        self.assertEqual(converted, '<p>%s</p>' % make_link('http://www.twitter.com/wdaher/status/2879779692873154569'))
 | 
			
		||||
 | 
			
		||||
        # id too large (i.e. tweet doesn't exist)
 | 
			
		||||
        msg = 'http://www.twitter.com/wdaher/status/999999999999999999'
 | 
			
		||||
        converted = convert(msg)
 | 
			
		||||
        self.assertEqual(converted, '<p>%s</p>' % make_link('http://www.twitter.com/wdaher/status/999999999999999999'))
 | 
			
		||||
 | 
			
		||||
        msg = 'http://www.twitter.com/wdaher/status/287977969287315456'
 | 
			
		||||
        converted = convert(msg)
 | 
			
		||||
        self.assertEqual(converted, '<p>%s</p>\n%s' % (make_link('http://www.twitter.com/wdaher/status/287977969287315456'),
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user