From 26f513a7a763adb8807f903cb013838d1c6175bf Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 22 May 2013 09:09:50 +0900 Subject: [PATCH] strip all non-src elements when copying&pasting images between fields --- aqt/editor.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/aqt/editor.py b/aqt/editor.py index 2fb52131c..fd72080c4 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -315,8 +315,9 @@ def _filterHTML(html): else: # remove completely tag.replaceWithChildren() - # turn file:/// links into relative ones + # now images for tag in doc("img"): + # turn file:/// links into relative ones try: if tag['src'].lower().startswith("file://"): tag['src'] = os.path.basename(tag['src']) @@ -324,6 +325,10 @@ def _filterHTML(html): # for some bizarre reason, mnemosyne removes src elements # from missing media pass + # strip all other attributes, including implicit max-width + for attr, val in tag.attrs: + if attr != "src": + del tag[attr] # strip superfluous elements for elem in "html", "head", "body", "meta": for tag in doc(elem):