From 00d48bff7dd1227a025d03c01d78a0027412cb87 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Sat, 21 Jan 2017 22:20:29 -0800 Subject: [PATCH] Digest: Fix URIs for emoji and friends in email links. It turns out we were using malformed URLs in the image tags (containing just a hostname, but no http(s)!) in what we were passing to the Django templates for our digest/, which resulted in the Django templates treating these URLs as http. Gmail recently cracked down on loading images in HTTP, causing the emoji links to appear broken in emails Zulip sends. Fixes #3258. --- zerver/lib/digest.py | 2 +- zerver/lib/notifications.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/zerver/lib/digest.py b/zerver/lib/digest.py index bcc152debf..629b0977aa 100644 --- a/zerver/lib/digest.py +++ b/zerver/lib/digest.py @@ -121,7 +121,7 @@ def gather_new_streams(user_profile, threshold): new_streams = list(get_active_streams(user_profile.realm).filter( invite_only=False, date_created__gt=threshold)) - base_url = u"https://%s/#narrow/stream/" % (settings.EXTERNAL_HOST,) + base_url = u"%s/#narrow/stream/" % (user_profile.realm.uri,) streams_html = [] streams_plain = [] diff --git a/zerver/lib/notifications.py b/zerver/lib/notifications.py index 1e4bebb46b..0700a7b97f 100644 --- a/zerver/lib/notifications.py +++ b/zerver/lib/notifications.py @@ -98,7 +98,7 @@ def build_message_list(user_profile, messages): # structure of the URL to leverage. content = re.sub( r"/user_uploads/(\S*)", - settings.EXTERNAL_HOST + r"/user_uploads/\1", content) + user_profile.realm.uri + r"/user_uploads/\1", content) # Our proxying user-uploaded images seems to break inline images in HTML # emails, so scrub the image but leave the link. @@ -108,8 +108,8 @@ def build_message_list(user_profile, messages): # URLs for emoji are of the form # "static/generated/emoji/images/emoji/snowflake.png". content = re.sub( - r"static/generated/emoji/images/emoji/", - settings.EXTERNAL_HOST + r"/static/generated/emoji/images/emoji/", + r"/static/generated/emoji/images/emoji/", + user_profile.realm.uri + r"/static/generated/emoji/images/emoji/", content) return content