mirror of https://github.com/zulip/zulip.git
markdown: Fix Dropbox image previews.
?dl=1 causes Dropbox to send Content-Type: application/binary, which can’t be interpreted by Camo. Use ?raw=1 instead. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
22b1f6e1ab
commit
bac96cae80
|
@ -829,7 +829,7 @@ class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor):
|
|||
image_info = {}
|
||||
image_info["is_image"] = True
|
||||
parsed_url_list = list(parsed_url)
|
||||
parsed_url_list[4] = "dl=1" # Replaces query
|
||||
parsed_url_list[4] = "raw=1" # Replaces query
|
||||
image_info["image"] = urllib.parse.urlunparse(parsed_url_list)
|
||||
|
||||
return image_info
|
||||
|
|
|
@ -778,7 +778,7 @@ class MarkdownTest(ZulipTestCase):
|
|||
|
||||
self.assertEqual(
|
||||
converted,
|
||||
f"""<p>Look at how hilarious our old office was: <a href="https://www.dropbox.com/s/ymdijjcg67hv2ta/IMG_0923.JPG">https://www.dropbox.com/s/ymdijjcg67hv2ta/IMG_0923.JPG</a></p>\n<div class="message_inline_image"><a href="https://www.dropbox.com/s/ymdijjcg67hv2ta/IMG_0923.JPG" title="IMG_0923.JPG"><img src="{get_camo_url("https://www.dropbox.com/s/ymdijjcg67hv2ta/IMG_0923.JPG?dl=1")}"></a></div>""",
|
||||
f"""<p>Look at how hilarious our old office was: <a href="https://www.dropbox.com/s/ymdijjcg67hv2ta/IMG_0923.JPG">https://www.dropbox.com/s/ymdijjcg67hv2ta/IMG_0923.JPG</a></p>\n<div class="message_inline_image"><a href="https://www.dropbox.com/s/ymdijjcg67hv2ta/IMG_0923.JPG" title="IMG_0923.JPG"><img src="{get_camo_url("https://www.dropbox.com/s/ymdijjcg67hv2ta/IMG_0923.JPG?raw=1")}"></a></div>""",
|
||||
)
|
||||
|
||||
msg = "Look at my hilarious drawing folder: https://www.dropbox.com/sh/cm39k9e04z7fhim/AAAII5NK-9daee3FcF41anEua?dl="
|
||||
|
|
Loading…
Reference in New Issue