From 8516ed86555c4b4a96186c6d92bc8a3d4532b82f Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 1 Jun 2020 07:33:11 +1000 Subject: [PATCH] handle images served from directory + svg content type https://anki.tenderapp.com/discussions/ankidesktop/41974-win-linux-when-pasting-some-html-i-get-error-in-_run_command-ankirsbackendioerror-ioerror --- pylib/anki/media.py | 1 + qt/aqt/editor.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/pylib/anki/media.py b/pylib/anki/media.py index 2d88ac543..c7731426c 100644 --- a/pylib/anki/media.py +++ b/pylib/anki/media.py @@ -112,6 +112,7 @@ class MediaManager: type_map = { "image/jpeg": ".jpg", "image/png": ".png", + "image/svg+xml": ".svg", } if content_type in type_map: fname += type_map[content_type] diff --git a/qt/aqt/editor.py b/qt/aqt/editor.py index 56416e279..c3f292e9f 100644 --- a/qt/aqt/editor.py +++ b/qt/aqt/editor.py @@ -837,6 +837,8 @@ to a cloze type first, via Edit>Change Note Type.""" # strip off any query string url = re.sub(r"\?.*?$", "", url) fname = os.path.basename(urllib.parse.unquote(url)) + if not fname.strip(): + fname = "paste" if content_type: fname = self.mw.col.media.add_extension_based_on_mime(fname, content_type)