From 00a8a4417bbed5a609adb33039f47d711fd0e404 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Fri, 25 Aug 2023 01:23:15 +1200 Subject: [PATCH] buildmimetree.py: handle image URLs starting with cid: --- .config/neomutt/buildmimetree.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.config/neomutt/buildmimetree.py b/.config/neomutt/buildmimetree.py index 97ada97..e2a23a7 100755 --- a/.config/neomutt/buildmimetree.py +++ b/.config/neomutt/buildmimetree.py @@ -266,6 +266,9 @@ def collect_inline_images( ): relparts = [] for path, info in images.items(): + if path.startswith("cid:"): + continue + data = request.urlopen(path) mimetype = data.headers["Content-Type"] @@ -948,6 +951,23 @@ try: assert tree.children[1].path == written[0] assert written[1] == request.urlopen(test_png).read() + def test_converter_tree_inline_image_cid( + self, const1, fake_filewriter + ): + text = f"![inline base64 image](cid:{const1})" + path = pathlib.Path(const1) + tree = convert_markdown_to_html( + text, + path, + filewriter_fn=fake_filewriter, + related_to_html_only=False, + ) + assert len(tree.children) == 2 + assert tree.children[0].cid != const1 + assert tree.children[0].type != "image" + assert tree.children[1].cid != const1 + assert tree.children[1].type != "image" + def test_inline_image_collection( self, test_png, const1, const2, fake_filewriter ): -- 2.39.5