From 53429428e905a5ae2f135d6d1709290f23ca3333 Mon Sep 17 00:00:00 2001 From: Lertsenem Date: Wed, 27 Jan 2021 00:58:56 +0100 Subject: [PATCH] Fix bug with special chars in filenames When exporting svg, if an image file name contains a "&", it will be escaped as "&" following html encoding. But when then asked to embed the png into the svg for export, the file won't be found with the sequence escaped. The solution is to unescape (using html.parser.unescape) the line before extracting the png url. --- lokrez/export.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lokrez/export.py b/lokrez/export.py index 5129954..a95e763 100644 --- a/lokrez/export.py +++ b/lokrez/export.py @@ -1,4 +1,5 @@ import base64 +import html import io import os import subprocess @@ -57,6 +58,7 @@ def generate_outfile( if ( l.startswith("xlink:href=\"file://") and l.endswith(".png\"") ): + l = html.parser.unescape(l) image_url = urllib.parse.urlparse( "=".join( l.split("=")[1:] )[1:-1], ) @@ -234,6 +236,7 @@ def generate_pic( if ( l.startswith("xlink:href=\"") and l.endswith(".png\"") ): + l = html.parser.unescape(l) image_url = urllib.parse.urlparse( "=".join( l.split("=")[1:] )[1:-1], )