From 5b1cfbc977101a32f020c50d1384eacbd39f499d Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Mon, 13 Jun 2016 19:09:33 -0700 Subject: [PATCH] bugdown: Fix extraction of titles for uploaded files. The previous code was associated with a previous version of the upload URL naming scheme, and thus never triggered in practice. --- zerver/lib/bugdown/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zerver/lib/bugdown/__init__.py b/zerver/lib/bugdown/__init__.py index cbb3910aec..1b43b790f0 100644 --- a/zerver/lib/bugdown/__init__.py +++ b/zerver/lib/bugdown/__init__.py @@ -630,13 +630,13 @@ class ModalLink(markdown.inlinepatterns.Pattern): return a_tag -upload_re = re.compile(ur"^(?:https://%s.s3.amazonaws.com|/user_uploads/\d+)/[^/]*/([^/]*)$" % (settings.S3_BUCKET,)) +upload_re = re.compile(ur"^(https?://[^/]*)?(/user_uploads/\d+)(/[^/]*)?/[^/]*/(?P[^/]*)$") def url_filename(url): # type: (text_type) -> text_type """Extract the filename if a URL is an uploaded file, or return the original URL""" match = upload_re.match(url) if match: - return match.group(1) + return match.group('filename') else: return url