Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions markdown/inlinepatterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,12 @@ def sanitize_url(self, url):

for part in url[2:]:
if ":" in part:
# A colon in "path", "parameters", "query"
# or "fragment" is suspect.
return ''
# Check if this is just Twitter media link with 'size'
colon_regex = re.compile('[/\w]*?\.(jpe?g|png|gif)(:large)?')
if not colon_regex.match(part):
# If not -- a colon in "path", "parameters", "query"
# or "fragment" is suspect.
return ''

# Url passes all tests. Return url as-is.
return urlunparse(url)
Expand Down